Results 1 to 8 of 8

Thread: Please Help me!!

  1. #1

    Thread Starter
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    I want to be able to find a specific text inside a RichTextBox and then if the text is found then it pops a message box out. i tried many different ways but still cant do it. please help me
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  2. #2
    Guest
    Use the RichTextBox's Find property.

    Code:
    RichTextBox1.Find "MyText"
    RichTextBox1.SetFocus
    Or you can use the Instr function.

    Code:
    If Instr(RichTextBox1.Text, "MyText") Then
    Msgbox "Text found!"
    Else
    Msgbox "Text not found!"
    End If

  3. #3

    Thread Starter
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    thanx. that works perfectly
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  4. #4
    Guest
    If you are using the first one, as you wanted a message box:

    Code:
        RichTextBox1.Find "MyText"
        RichTextBox1.SetFocus
        If RichTextBox1.SelText <> "" Then
            MsgBox "Text found!"
        Else
            MsgBox "Text not found!"
        End If

  5. #5
    Guest
    InStr can return the position of it as well.
    Code:
    nPosition = InStr(RTF1, "MyText")

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If the purpose is just to find it, not specify it's position you can do it faster with like operator:
    Code:
    If RichTextBox1.Text, "*MyText*") Then
      Msgbox "Text found!"
    Else
      Msgbox "Text not found!"
    End If
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Guest
    Your code is somewhat faulty, Kedaman.
    Code:
    If RichTextBox1.Text Like "*MyText*" Then
      MsgBox "Text found!"
    Else
      MsgBox "Text not found!"
    End If

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Red face

    Ooops! Too tired maybe?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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