Printing in .net
-
I had a vb6 project I am upgrading, in that project I had a subroutine that I used to print results such that a string of data would appear in a different column. The end result being an example as illustrated below (the 'Y's are passed as a string and this procedure wrapped them.) Not real pretty but it worked if a fixed font was used. sample output: (the Y string is actually a series of numbers separated by commas) XXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ZZZZ YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY the code:
Sub subPrintResults(slot As Integer, toPrint As String, Result As String, qty As Integer)
Dim i As Integer Dim chr As String Printer.CurrentX = 2000 ' first place to results line Printer.Print Result; ' this is the 'XXXXX in the example above Printer.CurrentX = 3000 'if we have a long string If Len(toPrint) > 90 Then i = 0 ' look for last comma, starting back 1 Do Until chr = "," chr = Mid$(toPrint, 90 - i, 1) i = i + 1 Loop Printer.Print Mid$(toPrint, 2, 90 - i) Printer.CurrentX = 3000 Printer.Print Mid$(toPrint, 90 - i + 2, Len(toPrint) - 90 - i + 1); Else Printer.Print Mid$(toPrint, 2, Len(toPrint) - 2); End If Printer.CurrentX = 10000 Printer.Print Format$(qty, "@@@@@")
Exit Sub
Can anyone point me to a way to determine the length of a string in vb .net to be output so I can reproduce this type of functionality? Thanks No-e edit looks like the alignment in my example was thrown off when I posted, all the YYYYs in the example should be in a single column.
-
I had a vb6 project I am upgrading, in that project I had a subroutine that I used to print results such that a string of data would appear in a different column. The end result being an example as illustrated below (the 'Y's are passed as a string and this procedure wrapped them.) Not real pretty but it worked if a fixed font was used. sample output: (the Y string is actually a series of numbers separated by commas) XXXXX YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY ZZZZ YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY YYYYYYYYY the code:
Sub subPrintResults(slot As Integer, toPrint As String, Result As String, qty As Integer)
Dim i As Integer Dim chr As String Printer.CurrentX = 2000 ' first place to results line Printer.Print Result; ' this is the 'XXXXX in the example above Printer.CurrentX = 3000 'if we have a long string If Len(toPrint) > 90 Then i = 0 ' look for last comma, starting back 1 Do Until chr = "," chr = Mid$(toPrint, 90 - i, 1) i = i + 1 Loop Printer.Print Mid$(toPrint, 2, 90 - i) Printer.CurrentX = 3000 Printer.Print Mid$(toPrint, 90 - i + 2, Len(toPrint) - 90 - i + 1); Else Printer.Print Mid$(toPrint, 2, Len(toPrint) - 2); End If Printer.CurrentX = 10000 Printer.Print Format$(qty, "@@@@@")
Exit Sub
Can anyone point me to a way to determine the length of a string in vb .net to be output so I can reproduce this type of functionality? Thanks No-e edit looks like the alignment in my example was thrown off when I posted, all the YYYYs in the example should be in a single column.
Take a look at the
Graphics.MeasureString()
method.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Take a look at the
Graphics.MeasureString()
method.Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”