NDaphid
07-18-2003, 07:39 PM
Hi.
I'm designing a test for my company employees. Some of the answers will have to be inputed into textboxes.
When calculating the score (using: if textbox1 = "whatever"), how can I advance the score even if whatever is WHATEVER?
While I'm at it, how do I use wildcards? So that What ever = whatever?
Thanks!
Dim MyString as String
MyString = LCase(Text1)
If you put anything in Text1, MyString contains Text1 in lowercase.
(You can also use UCase for uppercase)
Iceplug
07-18-2003, 07:47 PM
I don't understand that wildcard bit, but, you can use the Like operator in VB to compare strings:
If Text1.Text Like "*what*ever*" Then MsgBox "Whatever~~!"
:)
:eek: :eek: Wow !! what is "Like" command??
NDaphid
07-18-2003, 08:08 PM
Dim MyString as String
MyString = LCase(Text1)
If you put anything in Text1, MyString contains Text1 in lowercase.
(You can also use UCase for uppercase)
I love it...so...
I'm putting Dim MyString as String in the declarations section.
I'm putting MyString = LCase(Text1) in my click function right before the line: if text1.text Like "whatever" then score = score + 1.
My score is still 0 though. (When I use lowercase it is 1).
What am I doing wrong?
The StrComp function is the way I'd do it:If StrComp(Textbox1.Text, "whatever", vbTextCompare) = 0 Then
'Advance the score
End If
NDaphid
07-18-2003, 08:10 PM
Right, right...
Had it right after another if.
Moved it into the IF function it referenced...that did the trick! Thanks!
Please choose a method, wheter using Like or LCase.
If LCase(Text1) = "whatever" then score = score + 1
-A people fill in the Text1 textbox : "WhAtEvEr":
the score increased
-A people fill in the Text1 textbox : "whatEVER":
the score increased
-A people fill in the Text1 textbox : "EverWhat":
the score not increased ;)
NDaphid
07-18-2003, 08:24 PM
Please choose a method, wheter using Like or LCase.
If LCase(Text1) = "whatever" then score = score + 1
-A people fill in the Text1 textbox : "WhAtEvEr":
the score increased
-A people fill in the Text1 textbox : "whatEVER":
the score increased
-A people fill in the Text1 textbox : "EverWhat":
the score not increased ;)
Awwwww....I can't use both methods together? There is but no way?
Iceplug
07-19-2003, 05:58 AM
Of course you can.
If LCase(Text1.Text) Like "*what*ever*" Then MsgBox "YAY!"
:)
passel
07-19-2003, 06:30 AM
Of course you can.
If LCase(Text1.Text) Like "*what*ever*" Then MsgBox "YAY!"
:)
Of course "Like" will not handle "everwhat", it is unreasonalble to expect
the word to match when it's backwards, but if absolutely necessary, you
could split it I suppose to be:
If LCase(Text1.Text) Like "*what*" and LCase(Text1.Text) Like "*ever*" then MsgBox "YAY!"
NDaphid
07-19-2003, 09:05 AM
That clears that up! Thank you again.