Results 1 to 7 of 7

Thread: Opps..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    93

    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..

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    93
    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..

  4. #4
    Hyperactive Member Bananafish's Avatar
    Join Date
    Jan 2001
    Posts
    394
    Does it have to be a Textbox? could you not use a ListBox?

  5. #5
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    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

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    93
    But how do I tell the command that I want it to read the first line?
    An elephant learning VB..

  7. #7
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207
    This should help some.

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim s1 As String
    3.         Dim s2 As String
    4.         Dim s3 As String
    5.         Dim sw As String = TextBox1.Text
    6.  
    7.         sw = TextBox1.Text
    8.  
    9.         s1 = sw.Remove(sw.IndexOf(vbCrLf), sw.Length - sw.IndexOf(vbCrLf))
    10.         sw = sw.Remove(0, sw.IndexOf(vbCrLf) + 2) 'we remove two extra characters because an vbcrlf is actually two characters
    11.  
    12.         s2 = sw.Remove(sw.IndexOf(vbCrLf), sw.Length - sw.IndexOf(vbCrLf))
    13.         sw = sw.Remove(0, sw.IndexOf(vbCrLf) + 2)
    14.  
    15.         s3 = sw
    16.  
    17.         MsgBox("Your three lines of data are:" & vbCrLf & "'" & s1 & "'" & vbCrLf & "'" & s2 & "'" & vbCrLf & "'" & s3 & "'")
    18.     End Sub
    19.  
    20.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    21.         TextBox1.Multiline = True
    22.         TextBox1.Text = "This is line 1" & vbCrLf
    23.         TextBox1.Text &= "This is line 2" & vbCrLf
    24.         TextBox1.Text &= "This is line 3"
    25.     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
  •  



Click Here to Expand Forum to Full Width