邓紫棋深圳演唱会2017:用VB如何画表

来源:百度文库 编辑:神马品牌网 时间:2024/04/21 00:11:47
在窗体中实现打印预览功能,实现以下非规范表格和数据的打印:
要求:1、第一行线的宽度是2,其他线条的宽度为1,并且表格的中间有虚线,表格右边不封口;
2、编写函数实现所有的打印功能,以便在窗体中进行打印的功能同样可以用到打印机上;
3、打印预览窗口背景色为白色、无标题栏、缺省最大化显示;
4、在打印预览窗口按任意键或者点任意处,关闭该窗口。
图如下:
能否把窗体和工程文件传给我,邮箱ylstart@263.net,谢谢。

Option Explicit
Dim cmdQuxianFlag As Boolean
Private quexian(13, 6000) As Variant
Private gyhDate As String
Private chaxun11 As String
Private chaxun2 As String
Private zsl As Integer
Private wy_wy As Single
Private br_br As Single
Private zsl1 As Integer
Private zsl11 As Integer
Private i As Integer
Private j As Integer
Private x As Integer
Private y As Integer
Private fnt As Integer
Private txt As Variant
Private txt0 As Variant
Private dy As Variant
Private dd As Variant
Private prnt_bm(300, 7) As Variant
'画曲线函数
Public Function xp1(colvb1 As Variant, xx1 As Variant, yy1 As Variant, txt1 As Variant)
Picture3.ForeColor = colvb1 'QBColor(14)
Picture3.CurrentX = xx1
Picture3.CurrentY = yy1
Picture3.Print txt1 '
End Function
'打印函数
Public Function prnt(x As Variant, y As Variant, fnt As Variant, txt0 As Variant)
Printer.CurrentX = x
Printer.CurrentY = y
Printer.FontSize = fnt
Printer.Print txt0
End Function
'画曲线代码
Private Sub cmdQuxian_Click()
Picture3.Visible = True
Picture3.Cls
colvb1 = vbBlue
xx1 = 100
yy1 = 150
txt1 = "℃"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 200
yy1 = 350
txt1 = "50"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 200
yy1 = 1850
txt1 = "40"
wp1 = xp1(colvb1, xx1, yy1, txt1)
yy1 = 3350
xx1 = 200
txt1 = "30"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 200
yy1 = 4850
txt1 = "20"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 200
yy1 = 6350
txt1 = "10"
wp1 = xp1(colvb1, xx1, yy1, txt1)
'Time坐标
colvb1 = vbRed
yy1 = 6500
xx1 = 400
txt1 = "0"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 1480
txt1 = "5"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 2560
txt1 = "10"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 3640
txt1 = "15"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 4720
txt1 = "20"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 5800
txt1 = "25 min"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 6880
txt1 = "30"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 7960
txt1 = "35"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 9040
txt1 = "40"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 10120
txt1 = "45"
wp1 = xp1(colvb1, xx1, yy1, txt1)
xx1 = 11200
txt1 = "50"
wp1 = xp1(colvb1, xx1, yy1, txt1)
'画格
Picture3.DrawWidth = 1 ' = dash
Picture3.DrawStyle = 0
Picture3.ForeColor = vbBlue
For i = 0 To 39
Picture3.Line (450, 550 + i * 150)-(500, 550 + i * 150)
Next
Picture3.DrawStyle = 2
For i = 0 To 8
Picture3.Line (450, 400 + i * 750)-(11300, 400 + i * 750)
Next
For i = 0 To 15
Picture3.Line (450, 1000 + i * 300)-(500, 1000 + i * 300)
Next
For i = 0 To 10
Picture3.Line (500 + i * 1080, 400)-(500 + i * 1080, 6400)
Next
Picture3.DrawStyle = 0
For j = 0 To zsl - 2
If Int(j / 40) - j / 40 = 0 Then
Picture3.DrawWidth = 1 ' = dash
Picture3.Line (j * 10.8 + 470, quexian(12, j) * -150 + 7900)-(j * 10.8 + 530, quexian(12, j) * -150 + 7900), vbGreen ', BF
Picture3.Line (j * 10.8 + 500, quexian(12, j) * -150 + 7935)-(j * 10.8 + 500, quexian(12, j) * -150 + 7865), vbGreen ', BF
Picture3.Line (j * 10.8 + 470, quexian(13, j) * -150 + 7935)-(j * 10.8 + 470, quexian(13, j) * -150 + 7865), vbBlue ', BF
Picture3.Line (j * 10.8 + 470, quexian(13, j) * -150 + 7935)-(j * 10.8 + 530, quexian(13, j) * -150 + 7935), vbBlue ', BF
Picture3.Line (j * 10.8 + 530, quexian(13, j) * -150 + 7935)-(j * 10.8 + 530, quexian(13, j) * -150 + 7865), vbBlue ', BF
Picture3.Line (j * 10.8 + 470, quexian(13, j) * -150 + 7865)-(j * 10.8 + 530, quexian(13, j) * -150 + 7865), vbBlue ', BF
Picture3.DrawWidth = 2 ' = dash
Picture3.Line (j * 10.8 + 475, quexian(10, j) * -150 + 7930)-(j * 10.8 + 525, quexian(10, j) * -150 + 7870), vbBlack
Picture3.Line (j * 10.8 + 475, quexian(10, j) * -150 + 7870)-(j * 10.8 + 525, quexian(10, j) * -150 + 7930), vbBlack
Picture3.DrawWidth = 1 ' = dash
Picture3.Line (j * 10.8 + 500, quexian(9, j) * -150 + 7865)-(j * 10.8 + 469, quexian(9, j) * -150 + 7917), vbCyan ', BF
Picture3.Line (j * 10.8 + 500, quexian(9, j) * -150 + 7865)-(j * 10.8 + 531, quexian(9, j) * -150 + 7917), vbCyan ', BF
Picture3.Line (j * 10.8 + 469, quexian(9, j) * -150 + 7917)-(j * 10.8 + 531, quexian(9, j) * -150 + 7917), vbCyan ', BF
Picture3.DrawWidth = 1 ' = dash
Picture3.Line (j * 10.8 + 490, quexian(8, j) * -150 + 7880)-((j + 1) * 10.8 + 510, quexian(8, j + 1) * -150 + 7920), vbRed, BF
Picture3.DrawWidth = 1 ' = dash
'picture3.Circle (j * 10.8 + 500, quexian(6, j) * -150 + 7900), 30, vbGreen
Picture3.Circle (j * 10.8 + 500, quexian(11, j) * -150 + 7900), 35, vbMagenta '-((j + 1) * 10.8 + 500, quexian(6, j + 1) * -150 + 7900), vbGreen ', BF
'picture3.Circle (j * 10.8 + 500, quexian(4, j) * -150 + 7900), 25, vbBlack
Else
Picture3.DrawWidth = 1 ' = dash
Picture3.Line (j * 10.8 + 500, quexian(8, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(8, j + 1) * -150 + 7900), vbRed ', BF
Picture3.Line (j * 10.8 + 500, quexian(9, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(9, j + 1) * -150 + 7900), vbCyan ', BF
Picture3.Line (j * 10.8 + 500, quexian(10, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(10, j + 1) * -150 + 7900), vbBlack ', BF
Picture3.Line (j * 10.8 + 500, quexian(11, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(11, j + 1) * -150 + 7900), vbMagenta ', BF
Picture3.Line (j * 10.8 + 500, quexian(12, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(12, j + 1) * -150 + 7900), vbGreen ', BF
Picture3.Line (j * 10.8 + 500, quexian(13, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(13, j + 1) * -150 + 7900), vbBlue ', BF
End If
Next
End Sub
'打印曲线代码
Private Sub cmdQuxian1_Click()
colvb = vbBlue
fnt = 8
y = 150
x = 100
txt0 = "℃"
dy = prnt(x, y, fnt, txt0)
x = 3000
txt0 = "曲线1"
dy = prnt(x, y, fnt, txt0)
x = 200
y = 350
txt0 = "50"
dy = prnt(x, y, fnt, txt0)
x = 200
y = 1850
txt0 = "40"
dy = prnt(x, y, fnt, txt0)
y = 3350
x = 200
txt0 = "30"
dy = prnt(x, y, fnt, txt0)
x = 200
y = 4850
txt0 = "20"
dy = prnt(x, y, fnt, txt0)
x = 200
y = 6350
txt0 = "10"
dy = prnt(x, y, fnt, txt0)
'Time坐标
colvb = vbRed
y = 6500
x = 400
txt0 = "0"
dy = prnt(x, y, fnt, txt0)
x = 1480
txt0 = "5"
dy = prnt(x, y, fnt, txt0)
x = 2560
txt0 = "10"
dy = prnt(x, y, fnt, txt0)
x = 3640
txt0 = "15"
dy = prnt(x, y, fnt, txt0)
x = 4720
txt0 = "20"
dy = prnt(x, y, fnt, txt0)
x = 5800
txt0 = "25 min"
dy = prnt(x, y, fnt, txt0)
x = 6880
txt0 = "30"
dy = prnt(x, y, fnt, txt0)
x = 7960
txt0 = "35"
dy = prnt(x, y, fnt, txt0)
x = 9040
txt0 = "40"
dy = prnt(x, y, fnt, txt0)
x = 10120
txt0 = "45"
dy = prnt(x, y, fnt, txt0)
x = 11200
txt0 = "50"
dy = prnt(x, y, fnt, txt0)
y = 6800
x = 500
txt0 = PRINT_WzCs(1) & " 红色"
dy = prnt(x, y, fnt, txt0)
x = 2200
txt0 = PRINT_WzCs(2) & " 青色"
dy = prnt(x, y, fnt, txt0)
x = 3900
txt0 = PRINT_WzCs(3) & " 黑色"
dy = prnt(x, y, fnt, txt0)
x = 5600
txt0 = PRINT_WzCs(4) & " 紫红色"
dy = prnt(x, y, fnt, txt0)
x = 7300
txt0 = PRINT_WzCs(5) & " 绿色"
dy = prnt(x, y, fnt, txt0)
x = 9000
txt0 = PRINT_WzCs(6) & " 蓝色"
dy = prnt(x, y, fnt, txt0)
Printer.DrawWidth = 1 ' = dash
Printer.DrawStyle = 0
Printer.ForeColor = vbBlue
For i = 0 To 39
Printer.Line (450, 550 + i * 150)-(500, 550 + i * 150)
Next
Printer.DrawStyle = 2
For i = 0 To 8
Printer.Line (450, 400 + i * 750)-(11300, 400 + i * 750)
Next
For i = 0 To 15
Printer.Line (450, 1000 + i * 300)-(500, 1000 + i * 300)
Next
For i = 0 To 10
Printer.Line (500 + i * 1080, 400)-(500 + i * 1080, 6400)
Next
For j = 0 To zsl - 2
If Int(j / 40) - j / 40 = 0 Then
Printer.DrawWidth = 2 ' = dash
Printer.Line (j * 10.8 + 470, quexian(6, j) * -150 + 7900)-(j * 10.8 + 530, quexian(6, j) * -150 + 7900), vbGreen ', BF
Printer.Line (j * 10.8 + 500, quexian(6, j) * -150 + 7935)-(j * 10.8 + 500, quexian(6, j) * -150 + 7865), vbGreen ', BF
Printer.DrawWidth = 1 ' = dash
Printer.Line (j * 10.8 + 470, quexian(7, j) * -150 + 7935)-(j * 10.8 + 470, quexian(7, j) * -150 + 7865), vbBlue ', BF
Printer.Line (j * 10.8 + 470, quexian(7, j) * -150 + 7935)-(j * 10.8 + 530, quexian(7, j) * -150 + 7935), vbBlue ', BF
Printer.Line (j * 10.8 + 530, quexian(7, j) * -150 + 7935)-(j * 10.8 + 530, quexian(7, j) * -150 + 7865), vbBlue ', BF
Printer.Line (j * 10.8 + 470, quexian(7, j) * -150 + 7865)-(j * 10.8 + 530, quexian(7, j) * -150 + 7865), vbBlue ', BF
Printer.DrawWidth = 2 ' = dash
Printer.Line (j * 10.8 + 475, quexian(4, j) * -150 + 7930)-(j * 10.8 + 525, quexian(4, j) * -150 + 7870), vbBlack
Printer.Line (j * 10.8 + 475, quexian(4, j) * -150 + 7870)-(j * 10.8 + 525, quexian(4, j) * -150 + 7930), vbBlack
Printer.DrawWidth = 1 ' = dash
Printer.Line (j * 10.8 + 500, quexian(3, j) * -150 + 7865)-(j * 10.8 + 469, quexian(3, j) * -150 + 7917), vbCyan ', BF
Printer.Line (j * 10.8 + 500, quexian(3, j) * -150 + 7865)-(j * 10.8 + 531, quexian(3, j) * -150 + 7917), vbCyan ', BF
Printer.Line (j * 10.8 + 469, quexian(3, j) * -150 + 7917)-(j * 10.8 + 531, quexian(3, j) * -150 + 7917), vbCyan ', BF
Printer.DrawWidth = 1 ' = dash
Printer.Line (j * 10.8 + 490, quexian(2, j) * -150 + 7880)-((j + 1) * 10.8 + 510, quexian(2, j + 1) * -150 + 7920), vbRed, BF
Printer.DrawWidth = 1 ' = dash
'printer.Circle (j * 10.8 + 500, quexian(6, j) * -150 + 7900), 30, vbGreen
Printer.Circle (j * 10.8 + 500, quexian(5, j) * -150 + 7900), 35, vbMagenta '-((j + 1) * 10.8 + 500, quexian(6, j + 1) * -150 + 7900), vbGreen ', BF
'printer.Circle (j * 10.8 + 500, quexian(4, j) * -150 + 7900), 25, vbBlack
Else
Printer.DrawWidth = 1 ' = dash
Printer.Line (j * 10.8 + 500, quexian(2, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(2, j + 1) * -150 + 7900), vbRed ', BF
Printer.Line (j * 10.8 + 500, quexian(3, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(3, j + 1) * -150 + 7900), vbCyan ', BF
Printer.Line (j * 10.8 + 500, quexian(4, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(4, j + 1) * -150 + 7900), vbBlack ', BF
Printer.Line (j * 10.8 + 500, quexian(5, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(5, j + 1) * -150 + 7900), vbMagenta ', BF
Printer.Line (j * 10.8 + 500, quexian(6, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(6, j + 1) * -150 + 7900), vbGreen ', BF
Printer.Line (j * 10.8 + 500, quexian(7, j) * -150 + 7900)-((j + 1) * 10.8 + 500, quexian(7, j + 1) * -150 + 7900), vbBlue ', BF
End If
Next
Printer.EndDoc
End Sub
仅供参考.