Ok - I think I understand your question.
You have a string that is too big for the printer to print on one line.
So you need to cut it up.
I ripped this from a program we have here - I had to make edits in NOTEPAD to remove a whole lot of other stuff it was doing - hopefully it will work for you as is. x, y and z are dim'd long and strPara is the string to print.
VB Code:
Do While Len(strPara) y = Printer.Width ' Width in twips of printer If Printer.TextWidth(strPara) > y Then ' Size of what we want to print is too big z = Len(strPara) ' Length of it in characters Do While Printer.TextWidth(Left(strPara, z)) > y z = z - 1 ' Backup until it will fit Loop y = z ' Position that fits z = Asc(Mid(strPara, y + 1, 1)) ' ASC value of next character If z <> 32 Then ' That next character is not a space z = Asc(Mid(strPara, y, 1)) Do While z <> 32 ' Start backing up till we find the space y = y - 1 z = Asc(Mid(strPara, y, 1)) Loop End If Printer.Print Trim(Left(strPara, y)) strPara = Mid(strPara, y + 1) Else Printer.Print Trim(strPara) Exit Do End If Loop




Reply With Quote