'***********************************************************************************************
'功能:Printer字符串的纵向横向换行打印过程
'过程:CutPrint(str As String, x As Integer, xstep, y As Integer, ystep As Integer, Flag As String, HV As String)
'调用:Call CutPrint("湖南张家界,12345,xxxxx", 100, 400, 200, 400,",","H")
'参数:str:要打印的字符串,Flag:字符串分割符的标记,比如 ,
'参数: x , y每个要打印的字符串对应的x, y坐标
'参数: xstep,ystep: 每个要打印的字符串对应的X,y的步长
'参数: HV,H表示纵向换行打印,V表示横向换行打印
'作者:FlashAsp
'Q Q:21792038
'日期:2007-04-13
'***********************************************************************************************
Public Sub CutPrint(str As String, X As Integer, xstep, Y As Integer, ystep As Integer, Flag As String, HV As String)
Dim i As Integer
Dim a
a = Split(str, Flag)
For j = 0 To UBound(a)
If HV = "H" Then '纵向换行打印
For i = 1 To Len(a(j))
Printer.CurrentX = X + xstep * j
Printer.CurrentY = Y + ystep * (i - 1)
Printer.Print Mid(CStr(a(j)), i, 1)
Next
Else '横向换行打印 V
Printer.CurrentX = X
Printer.CurrentY = Y + ystep * j
Printer.Print Left(CStr(a(j)), Len(a(j)))
End If
Next
'Printer.EndDoc '本过程放到其他PRITER中的时候注释掉此行
End Sub
'***********************************************************************************************
'1.Call CutPrint("湖南张家界,12345,xxxxx", 100, 400, 200, 400, ",", "H")
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'输出打印结果:
'
'湖 1 x
'南 2 x
'张 3 x
'家 4 x
'界 5 x
'
'2.Call CutPrint("湖南张家界,12345,xxxxx", 100, 400, 200, 400, ",", "V")
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'输出结果:
'
'湖南张家界
'12345
'xxxxx
'***********************************************************************************************