求VS2010下的VB格式打印范例程序

min2max 2012-08-09 10:21:46
我对VB不熟悉,朋友让我帮做个简单的计算程序——包括一系列数据输入(并不太多,可能用Edit控件,也可能结合grid),然后作一些简单计算,并能以自定义格式打印计算报告。

现在我主要对VB的格式打印感觉有困难。请问哪位有比较好的范例?

除了格式打印,其他方面如也能接近我的需求,那更好。多谢。

(我对C++比较熟悉)

我仿照别人的代码写了这么一段代码。但点击Print按钮的时候出错(未处理的异常)。


Imports System.Drawing.Printing

Public Class Form1
Public ShipLength As String
Public ShipWidth As String

Friend WithEvents print As PrintDocument
'Dim print As PrintDocument

Private Sub Print_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles print.PrintPage
ShipLength = EditShipLength.Text
ShipWidth = EditShipWidth.Text

e.Graphics.DrawString("打印示例", New Font("宋体", 40, FontStyle.Regular), Brushes.Black, 160, 80)
e.Graphics.DrawString("L : ", New Font("宋体", 15, FontStyle.Regular), Brushes.Black, 20, 200)
e.Graphics.DrawString(ShipLength, New Font("宋体", 15, FontStyle.Regular), Brushes.Black, 220, 200)
e.Graphics.DrawString("B : ", New Font("宋体", 15, FontStyle.Regular), Brushes.Black, 20, 230)
e.Graphics.DrawString(ShipWidth, New Font("宋体", 15, FontStyle.Regular), Brushes.Black, 220, 230)
End Sub

Private Sub ButtonCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCalculate.Click, ButtonClose.Click

End Sub

Private Sub ButtonClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCalculate.Click, ButtonClose.Click
Me.Close()
End Sub

Private Sub ButtonPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrint.Click
print.Print()
End Sub

End Class

请高手帮我看一下。谢谢!
...全文
43 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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