Sorry for the double posting .. Now comes another question from me..
How do I create some kind like a pointer for it to indicate that on which line it is on a textbox?
Eg like I want it to go to Line 3 of the text in Textbox?
Printable View
Sorry for the double posting .. Now comes another question from me..
How do I create some kind like a pointer for it to indicate that on which line it is on a textbox?
Eg like I want it to go to Line 3 of the text in Textbox?
I guess I am not understanding the question. What do you mean? Are you only going to deal with one line at a time or can the text be spread across serveral lines? If you are looking to see what line it starts on the you can get the position of where you string starts and count how many "vbcrlf"'s are before your statring position. That will give you starting line. You can also count how many are in and after your string that would tell you how many lines your string expands and how many lines are after it.
Jeremy
I mean for example.. I have these in a Textbox
Hi.
How are you?
I'm fine.
End
And I want the command for reading these line by line because I want them to be compared with the word "End"
It goes..
Do
Compare Line X in Textbox with the word "End"
If it's End
Textbox2 show "Found"
Else
Line X=Line + 1
Until EOL
Roughly something like that..
Does it have to be a Textbox? could you not use a ListBox?
If you want to find out what line the word END is on just search for it using the indexof then search the textbox.text for "vbcrlf"'s and that will tell you what line it is on.
Jeremy
But how do I tell the command that I want it to read the first line?
This should help some.
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s1 As String Dim s2 As String Dim s3 As String Dim sw As String = TextBox1.Text sw = TextBox1.Text s1 = sw.Remove(sw.IndexOf(vbCrLf), sw.Length - sw.IndexOf(vbCrLf)) sw = sw.Remove(0, sw.IndexOf(vbCrLf) + 2) 'we remove two extra characters because an vbcrlf is actually two characters s2 = sw.Remove(sw.IndexOf(vbCrLf), sw.Length - sw.IndexOf(vbCrLf)) sw = sw.Remove(0, sw.IndexOf(vbCrLf) + 2) s3 = sw MsgBox("Your three lines of data are:" & vbCrLf & "'" & s1 & "'" & vbCrLf & "'" & s2 & "'" & vbCrLf & "'" & s3 & "'") End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Multiline = True TextBox1.Text = "This is line 1" & vbCrLf TextBox1.Text &= "This is line 2" & vbCrLf TextBox1.Text &= "This is line 3" End Sub
Jeremy