Results 1 to 10 of 10

Thread: searching a textbox for letters and numbers

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I have a text box, and I want the user to enter any thing into a text box, and then click ok, then my program searches the text box for the number 123, if it find it then a message box comes up saying that it found it, if not, then a message box comes up saying that it didn't find the number in it

    I hope that was clear

    thanks in advance


    dimava
    NXSupport - Your one-stop source for computer help

  2. #2
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Code:
    If InStr(1, Text1.Text, "123") Then
         MsgBox("123 Found"), , "String Match"
    Else:
         retval = MsgBox("123 Not Found"), vbExclamation Or vbOkOnly, "String Not Found"
    End If
    I hope this is what you were looking for,

    Me


    [Edited by V(ery) Basic on 07-28-2000 at 02:26 PM]
    Courgettes.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Thanks
    NXSupport - Your one-stop source for computer help

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I tried it and a error message comes up

    the 2 lines that that say message box come up in red
    NXSupport - Your one-stop source for computer help

  5. #5
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    Make them look like this:
    If InStr(1, Text1.Text, "123") Then
    MsgBox "123 Found", , "String Match"
    Else
    retval = MsgBox("123 Not Found", vbExclamation Or vbOKOnly, "String Not Found")
    End If

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You could use Like operator, it's definitely faster
    Code:
    If Text1.Text Like "*123*" Then...
    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

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok, thanks to all for your help
    NXSupport - Your one-stop source for computer help

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    one more question....

    I ahev it search for "AbC*"
    I need the * to be a single digit number

    now what if the * is not a number, its a letter
    is there a way to make it so that if the * isn't a number then it clears text1.text?

    I hope I was clear, if not I can try to re-explain myself
    NXSupport - Your one-stop source for computer help

  9. #9
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    Use The # character instead of *.

  10. #10
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Dim x As String
    x = Right(Text1, 4)

    If Asc(x) < 80 Or Asc(x) > 89 Then
    MsgBox "no number"
    End If
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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