|
-
Jan 11th, 2000, 06:51 PM
#1
Thread Starter
Lively Member
As I do to catch each line of a Textbox whose multiline = true
------------------
The blessing of God enriches and it doesn't increase pains
-
Jan 12th, 2000, 09:19 AM
#2
Hyperactive Member
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, 07:37 PM
#3
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
-
Jan 12th, 2000, 08:10 PM
#4
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).]
-
Jan 14th, 2000, 01:18 AM
#5
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|