-
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
-
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]
-
-
I tried it and a error message comes up
the 2 lines that that say message box come up in red
-
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
-
You could use Like operator, it's definitely faster
Code:
If Text1.Text Like "*123*" Then...
-
ok, thanks to all for your help
-
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
-
Use The # character instead of *.
-
<?>
Dim x As String
x = Right(Text1, 4)
If Asc(x) < 80 Or Asc(x) > 89 Then
MsgBox "no number"
End If