Results 1 to 5 of 5

Thread: textbox with multiline true

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Sao Paulo - SP - BRAZIL
    Posts
    65

    Post

    As I do to catch each line of a Textbox whose multiline = true

    ------------------
    The blessing of God enriches and it doesn't increase pains

  2. #2
    Hyperactive Member Juan Carlos Rey's Avatar
    Join Date
    Aug 1999
    Location
    Mendoza, Argentina
    Posts
    301

    Post

    I don't know exactly what you mean, but if it is how to retrieve the whole text, is the same as any other text box, for ex.

    MyText = Text1.Text

    If you want to separate the text into individual lines, split it using vbCrLf, like this:

    ----------
    MyText = Text1.Text
    Dim i, p, q as Integer
    Dim Line(100) as String
    p = InStr (MyText, vbCrLf)
    Line(i) = left (text1.Text, p)
    While p
    MyText = Right (Text1.Text, Len(text1.Text) - p - 1)
    q = p
    p = InStr (q, MyText, vbCrLf)
    i = i + 1
    Line(i) = left (text1.Text, p)
    Wend
    ----------

    Not tested, I do not have VB in this machine, but this is the approach.

    (Sorry for the innaccuracy but nobody answered)

  3. #3
    Guest

    Post

    Find where the carriage return character is placed.
    When you reach the carriage return character, the character before it represents one line.

    I have put a sample code below:

    The name of the textbos is txtMult.

    Dim i As Integer 'The position of the Carriage Return character.
    Dim intLineNo As Integer 'The Line No.
    Dim intStartPos As Integer 'The Start Position of a line.

    'Initialize.
    i = 1: intLineNo = 1: intStartPos = 1

    'Start search.
    'chr(13) represents the Carriage Return character.
    While (i <= Len(txtMult.Text))
    i = InStr(i, txtMult.Text, Chr(13), vbBinaryCompare)
    If (i = 0) Then
    'We have reached the last line.
    MsgBox "Line " & intLineNo & ": " & Mid(txtMult, intStartPos)
    Exit Sub
    End If
    MsgBox "Line " & intLineNo & ": " & Mid(txtMult, intStartPos, i - intStartPos + 1)
    intStartPos = i + 1 'New text reading Starting Position.
    i = i + 1 'Next Search Position.
    intLineNo = intLineNo + 1 'New Line No.
    Wend

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    If you only show the vertical scrollbar the text will wrap without you pressing the enter key, so searching for the carriage return | line feed characters will not do you any good.

    Read my article on how to extract one line of text from a textbox.

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com




    [This message has been edited by Joacim Andersson (edited 01-13-2000).]

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Sao Paulo - SP - BRAZIL
    Posts
    65

    Post

    Unhappily none of the tips above gave right

    ------------------
    The blessing of God enriches and it doesn't increase pains

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width