Visual Basic > Applications-VBA
use wordwrapping while printing textbox
use wordwrapping while printing textbox >I'd like to print out text so say 20 characters max, when textbox contents >is maybe 100 long. Yes it's possible. I have a proc which will do it for you but you can only use it with a certain font and size. (Your user cannot choose another font/size because of the way the proc works). I made it in VB3, use it now in VB 4. Perhaps there is another way (must be) but it still works for me... 'maximum characters printed Const lengte_omschrijving% = 40 Private sub Afbreken(wat$, waar%) dim lcounter%, deel1$, lteller% lcounter = 1 do While lcounter < Len(wat$) deel1 = Mid$(wat$, lcounter, lengte_omschrijving) If lcounter + Len(deel1) < Len(wat$) Then For lteller = Len(deel1) To 1 Step -1 If Mid$(deel1, lteller, 1) = Chr(32) Then Printer.Print Tab(waar%); Printer.Print Mid$(wat$, lcounter, lteller) lcounter = lcounter + lteller lteller = 1 End If Next lteller Else Printer.Print Tab(waar%); Printer.Print deel1 lcounter = Len(wat$) End If Printer.Print Tab(waar%); Loop End Sub 'use as Call Afreken(text1.text,10) 'this will give you the contents of text1 printed with a left margin of 10 charachters and a length of 40; if necessary it's wrapped around a space. Return
Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows