PDA

Click to See Complete Forum and Search --> : textbox with multiline true


Marcelo Velasquez
Jan 11th, 2000, 05:51 PM
As I do to catch each line of a Textbox whose multiline = true

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

Juan Carlos Rey
Jan 12th, 2000, 08:19 AM
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)

Jan 12th, 2000, 06:37 PM
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

Joacim Andersson
Jan 12th, 2000, 07:10 PM
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 (http://www.vb-world.net/api/textboxex/) on how to extract one line of text from a textbox.

Good luck!

------------------
Joacim Andersson
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)




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

Marcelo Velasquez
Jan 14th, 2000, 12:18 AM
Unhappily none of the tips above gave right

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