Option Explicit
Public rowlab As Integer
Public PositionX As Integer
Public PositionY As Integer
'定義一個公用變量
'---- 注: Prnt11函數原形:prnt11(X As Integer, Y As Integer, Font As Single, Txt As String, Val As Integer),其各參數含義如下:
'
'---- X、Y為待打印字符串左上角起始座標;
'
'---- Font為字体大小;
'
'---- Txt為待打印字符串;
'
'---- Val為字符串打印折行長度。
Function prnt11(x As Integer, Y As _
Integer, Font As Single, Txt As String, Val As Integer)
Dim str As String, str1 As String, str2 As String, i As Integer
Printer.CurrentX = x
Printer.CurrentY = Y
Printer.FontBold = False
Printer.FontSize = Font
str = Txt
str2 = str
i = 0
rowlab = 0
If Len(Trim(str)) = 0 Then
rowlab = 1 '待打印字符串為空的標志
Else
Do While Len(str) > 0
Printer.CurrentX = x
Printer.CurrentY = Y + rowlab * 240
rowlab = rowlab + 1
If Len(str) >= Val Then
str1 = Mid(str, 1, Val)
Printer.Print str1
i = i + 1
str = Mid(str2, i * Val + 1)
Else
Printer.Print str
Exit Do
End If
Loop
End If
End Function