-
My friend asked me this and i didn't know so i am asking you guys/gals....
He Has a button and a Textbox:
Code:
If text1.text = "Chris" then
form2.show
unload me
end if
But he wants it to work even if text1.text is:
ChRiS
chris
CHRIS
you know.. ANY case... but he doesn't want to do every kind of case there is for the name.
Any way for this to work?
-
do this:
Code:
If UCase$(text1.text) = "CHRIS" then
form2.show
unload me
end if
-
You can convert to upper case no matter what:
Code:
If Ucase(Text1.Text) = "CHRIS" Then
Form2.Show
Unload Me
End If
-
You could also use the StrComp method:
Code:
If StrComp(Text1.Text, "chris", vbTextCompare) = 0 Then
Form2.Show
Unload Me
End If
-
ew.. StrComp is a neet function, but it's too slow. UCase$ is much faster. I always use UCase$ over StrComp and UCase because it deals with Strings only, ie no Variant manipulating. (it's a VB programming habit I guess.)