VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Split String for Word Wrapping

Gajendra S. Dhir  (3 Submissions)   Miscellaneous   Visual Basic 3.0   Intermediate   Wed 3rd February 2021

Breaks up a string so that it can be effectively printed - word wrapped - using the Print statement.


SplitLines is a function in Visual Basic to return an array of strings from a long string such that the each array element has its P.TextWidth(Lines(i)) < W. The function uses the current font settings of the object P which could be a Form, a PictureBox or the Printer object.

Inputs

Txt     -> is the String that is to be split
P      -> a Form, a PictureBox or the Printer object. The font settings
        of this will be used to determine the TextWidth
W      -> the maximum width of the string array

Assumes
Example Usage =============

  Dim Ltxt() as string
  Dim OriStr as string
  OriStr = "This contains the string that is to be split...... ..."
  Ltxt = SplitLines(OriStr, Form1, 1500)
  For i = 1 to UBound(Ltxt)
    Form1.Print Ltxt(i)
  Next i

Returns
An array of strings.

Side Effects
The function counts on the fact that font characteristics for the object P has been set.

Rate Split String for Word Wrapping (6(6 Vote))
Split String for Word Wrapping.bas

Split String for Word Wrapping Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters