printer怎么换页的啊??

asiawen 2010-01-04 04:55:01
比如我想打印满了一个A4纸就换页,或者数据库读到三十条记录就换页,怎么写?
Private Sub Command1_Click()
Dim a As Integer
a = Text1.Text
For i = 1 To a
Printer.FontSize = 14
Printer.CurrentX = 6
Printer.CurrentY = 100
Printer.Print Tab(38); "排班表"
Printer.FontSize = 12
Printer.Print " ┌────┬───┬───┬─────────┬────┬──────┬───────────┐"
Printer.Print " │ 车牌 │公里 │ 油费 │ 地址 │司机编号│ 姓名 │ 日期时间 │"
Adodc4.Refresh
Do While Not Adodc4.Recordset.EOF
Printer.Print " ├────┼───┼───┼─────────┼────┼──────┼───────────┤"
Printer.Print Tab(2); "│"; Adodc4.Recordset.Fields("车牌"); Tab(12); "│"; Adodc4.Recordset.Fields("公里"); Tab(20); "│"; Adodc4.Recordset.Fields("油费"); Tab(28); "│"; Adodc4.Recordset.Fields("地址"); Tab(48); "│"; Adodc4.Recordset.Fields("司机编号"); Tab(58); "│"; Adodc4.Recordset.Fields("姓名"); Tab(72); "│"; Adodc4.Recordset.Fields("日期"); Tab(96); "│"; ""
Adodc4.Recordset.MoveNext
Loop
Printer.Print " └────┴───┴───┴─────────┴────┴──────┴───────────┘"
Adodc4.Refresh
Printer.EndDoc
Printer.KillDoc
Next i

End Sub
...全文
118 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
贝隆 2010-01-04
  • 打赏
  • 举报
回复
楼主,为什么不用Excel呢?使用Excel做一个模板,每次要使用的时候复制这个模板,然后向复制的文件中填写内容即可,要打印,只需要简单的一条语句即可,既简单又实用
king06 2010-01-04
  • 打赏
  • 举报
回复
加一个表头打印不就可以了,参考
Do While Not Adodc4.Recordset.EOF
If i > 29 Then
Printer.Print " ┌────┬───┬───┬─────────┬────┬──────┬───────────┐"
Printer.Print " │ 车牌 │公里 │ 油费 │ 地址 │司机编号│ 姓名 │ 日期时间 │"
Printer.NewPage
i = 0
End If
Printer.Print " ├────┼───┼───┼─────────┼────┼──────┼───────────┤"
Printer.Print Tab(2); "│"; Adodc4.Recordset.Fields("车牌"); Tab(12); "│"; Adodc4.Recordset.Fields("公里"); Tab(20); "│"; Adodc4.Recordset.Fields("油费"); Tab(28); "│"; Adodc4.Recordset.Fields("地址"); Tab(48); "│"; Adodc4.Recordset.Fields("司机编号"); Tab(58); "│"; Adodc4.Recordset.Fields("姓名"); Tab(72); "│"; Adodc4.Recordset.Fields("日期"); Tab(96); "│"; ""
Adodc4.Recordset.MoveNext
i = i + 1
Loop
windyhero1983 2010-01-04
  • 打赏
  • 举报
回复
^P换页
asiawen 2010-01-04
  • 打赏
  • 举报
回复
这样换了页没了表头啊
king06 2010-01-04
  • 打赏
  • 举报
回复
有个方法Printer.NewPage

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧