|
-
Nov 4th, 2001, 10:16 AM
#1
Thread Starter
Lively Member
text comparison
how do i code :-
whether a correct word had been typed into a text box
tink
-
Nov 4th, 2001, 10:28 AM
#2
Hyperactive Member
Do u mean that you want to check whether a user typed in a grammatical valid word?
-
Nov 4th, 2001, 10:48 AM
#3
Thread Starter
Lively Member
case comparison
yes its a specific word that has to be typed in txtbox so i just need how to check if user has typed in correct word.
tink
-
Nov 4th, 2001, 10:49 AM
#4
PowerPoster
if lcase(text1) like lcase("yourword") then
Msgbox "you got it right!"
else
msgbox"you got it wrong!"
end if
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 4th, 2001, 10:59 AM
#5
Thread Starter
Lively Member
case comparison
thanks arc
works a treat , ive got 20 of these txtboxes in all where is the best place to put code , ive put it in the click event but really want all 20 boxes finished before msgbox displays
sorry if this is a stupid question but im still learning
tink
-
Nov 4th, 2001, 11:19 AM
#6
Hyperactive Member
private sub txtbox_KeyUp(Keycode as integer, Shift as integer)
If keycode = vbkeyreturn then
'checkforvalidword
end if
end sub
-
Nov 4th, 2001, 11:35 AM
#7
PowerPoster
I'm not i understand exactly what you want, but here is what i would do.
Create a textbox array. This means that you name all of your textboxes the same, such as TxtCheckWord. When you name the second textbox the same as the first one it will ask you if want to create and array. Click yes. After all 20 textboxes are named the same you can proceed with your code.
Now i'm not sure if you are using the textboxes Click event or a buttons click event to check the textboxes, but in a click event put this code.
For i = 0 to 19
if txtCheckWord(i) = "" then
msgbox " you must fill in all the textboxes before you can check them"
exit sub"
next i
You see, now all your textboxes can be checked much easier. Each textbox now has a number next to it. Ranging form 0 to 19. That's the Index number.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Nov 4th, 2001, 11:36 AM
#8
PowerPoster
Re: case comparison
Originally posted by tink
where is the best place to put code , ive put it in the click event but really want all 20 boxes finished before msgbox displays
sorry if this is a stupid question but im still learning
tink
the Validate event would be best, then you can cancel the movement to another control if the contents don't fit requirements
-
Nov 4th, 2001, 12:08 PM
#9
Frenzied Member
You guys like to complicate stuff, don't you? 
Try this:
VB Code:
'When someone presses the button to see if it's right
Private Sub cmdSeeIfItsRight_Click()
If Text1.Text = "blah blah" And Text2.Text = "blah" And Text3.Text = "yeah" And Text4.Text = "testing" And Text5.Text = "i'm running out of ideas for this thing" Then
MsgBox "You got it right!!!"
Else
MsgBox "WRONG! Try again."
End If
End Sub
Just add as many textboxes as you need
-
Nov 4th, 2001, 12:46 PM
#10
PowerPoster
As Chris said, Validate Event:
Code:
Private Sub Text1_Validate(Cancel As Boolean)
If StrComp(Text1.Text, "Whatever", vbBinaryCompare) Then
MsgBox "Invalid Data"
Cancel = True: Text1.SetFocus
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|