|
-
Nov 7th, 2002, 12:45 AM
#1
Thread Starter
Lively Member
Opps..
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?
An elephant learning VB..
-
Nov 7th, 2002, 01:30 AM
#2
Addicted Member
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
Last edited by Jeremy Martin; Nov 7th, 2002 at 01:38 AM.
-
Nov 7th, 2002, 02:55 AM
#3
Thread Starter
Lively Member
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..
An elephant learning VB..
-
Nov 7th, 2002, 06:40 AM
#4
Hyperactive Member
Does it have to be a Textbox? could you not use a ListBox?
-
Nov 7th, 2002, 09:14 AM
#5
Addicted Member
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
-
Nov 7th, 2002, 07:52 PM
#6
Thread Starter
Lively Member
But how do I tell the command that I want it to read the first line?
An elephant learning VB..
-
Nov 7th, 2002, 10:33 PM
#7
Addicted Member
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
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
|