Results 1 to 2 of 2

Thread: Richtextbox/string manipulation problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    29

    Richtextbox/string manipulation problem

    I have this programming problem from Sams book learn vb 2003 in 21 days

    Add some text like "A noisy noise annoys an oyster, does it not? to a rich text box: then use a While loop to convert all instances of no in that text to italic.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    While (RichTextBox1.Find("No") <> -1)
    RichTextBox1.Find("No", 0, RichTextBoxFinds.None)
    Dim fntItalic As New Font(RichTextBox1.Font, FontStyle.Italic)
    RichTextBox1.SelectionFont = fntItalic

    End While
    End Sub

    I understand that because the While(RichTextBox1.Find("No") <> -1) will always be true because it finds "No" everytime it loops, somehow I have to eliminate those "No" that are already italized until the statement becomes, false. If anyone can help me, i'd appreciate it.

  2. #2
    Fanatic Member Graff's Avatar
    Join Date
    Jan 2002
    Location
    Calgary
    Posts
    668

    Re: Richtextbox/string manipulation problem

    Use the find method that uses the start location,

    StartLoc = 0
    while...
    FindLoc = richtextbox.find("No",startloc)
    'do stuff
    StartLoc = FindLoc + 1
    loop
    If wishes were fishes we'd all cast nets.

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