打印不出MSFlexGrid中的数据
Private Sub Command4_Click()Dim fnt As Single
Dim ss As String
Dim foot As String
Dim kan, i, n, o As Integer
Dim pp As Integer
pp = 0 '设置开始页码0
Dim stry, strx, strx1, stry1, linw, page1, p, dd, j, gridrow, grid1, st As Integer
Static a(8) As Integer '定义打印的列数
ss = "汽车油罐容积表" '定义表头
kan = 0
For i = 0 To 8
a(i) = 1200 '定义每列宽
kan = kan + a(i) '计算表格总宽度
Next
page1 = 30 '定义每页行数
strx = 200
strx1 = 200 '定义X方向起始位置
stry = 1400
stry1 = 1400 '定义Y方向起始位置
linw = 340 '定义行宽
fnt = 8 '定义字体大小
Printer.FontName = "宋体" '定义字体
dd = print1(4000, 700, 18, ss) '打印标题
Printer.Line (strx - 50, stry - 30)-(strx + kan - 10, stry - 30)
For j = 0 To MSFlexGrid2.rows- 1 'gridrow为所要打印的行数
MSFlexGrid2.row = j
strx = strx1
Printer.Line (strx - 50, stry - 30)-(strx + kan - 10, stry - 30)
p = p + 1
For i = 0 To 7
MSFlexGrid2.col = i
dd = print1(200, 1400, fnt, MSFlexGrid2.TextMatrix(j, i))
strx = strx + a(i)
Next
If p > page1 Then 'next page
p = 0
strx = strx1
'line last line
Printer.Line (strx - 50, stry + linw)-(strx + kan - 10, stry + linw)
stry = stry1
'line col
For n = 0 To 8
Printer.Line (strx - 30, stry - 30)-(strx - 30, stry + (page1 + 2) * linw)
strx = strx + a(n)
Next
Printer.Line (strx - 30, stry - 30)-(strx - 30, stry + (page1 + 2) * linw)
pp = pp + 1
foot = "第 " + CStr(pp) + "页"
dd = print1(strx - 30 - 1000, stry + (page1 + 2) * linw + 100, 10, foot) '打印页角码
Printer.NewPage 'next page
dd = print1(4000, 700, 18, ss) '打印标题
strx = strx1
stry = stry1
Printer.Line (strx - 50, stry - 30)-(strx + kan - 10, stry - 30) ' print first row
Else
stry = stry + linw
End If
Next
st = stry
If p < page1 Then '在最后页剩余划空行
For o = p To page1 + 1
strx = strx1
Printer.Line (strx - 50, stry - 30)-(strx + kan - 10, stry - 30)
stry = stry + linw
Next
End If
stry = stry1
strx = strx1
stry = stry1 'line col
For n = 0 To 8
Printer.Line (strx - 30, stry - 30)-(strx - 30, stry + (page1 + 2) * linw)
strx = strx + a(n)
Next
Printer.Line (strx - 30, stry - 30)-(strx - 30, stry + (page1 + 2) * linw)
pp = pp + 1
foot = "第 " + CStr(pp) + "页"
dd = print1(strx - 30 - 1000, stry + (page1 + 2) * linw + 100, 10, foot) '打印页角码
Printer.EndDoc '打印结束
End Sub
Function print1(x As Integer, y As Integer, font As Single, txt As String)
Printer.CurrentX = x
Printer.CurrentY = y
Printer.FontBold = False
Printer.FontSize = font
Printer.Print txt
End Function
这段程序为什么打印不出来MSFlexGrid中的数据呢.只是打印出标题和直线.