VB上如何打印窗体指定位置的内容?
1个回答
展开全部
VB可以用CurrentX、CurrentY 属性实现定位打印。用ScaleMode 属性确定打印机对象坐标的度量单位。
CurrentX、CurrentY 属性,返回或设置下一次打印或绘图方法的 水平 (CurrentX) 或垂直
(CurrentY) 坐标。
ScaleMode 属性,当使用图形方法或调整控件位置时,返回或设置一个值,该值指示对象坐标的度量单位。
具体实现代码:
Option Explicit
Dim X As Long
Dim y As Long
Dim fnt As Variant
Dim txt As String
Dim dy As Variant
Public Function prnt(X As Variant, y As Variant, fnt As Variant, txt As Variant)
Printer.CurrentX = X
Printer.CurrentY = y
Printer.FontSize = fnt
Printer.Print txt
End Function
Private Sub Command1_Click()
Printer.ScaleMode = 6 '以mm定位
Printer.CurrentX = 10
Printer.CurrentY = 20
fnt = 12
txt = "YD(0)"
dy = prnt(X, y, fnt, txt)
Printer.EndDoc
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询