Results 1 to 10 of 10

Thread: text comparison

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Location
    cornwall, England
    Posts
    110

    text comparison

    how do i code :-
    whether a correct word had been typed into a text box
    tink

  2. #2
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    Do u mean that you want to check whether a user typed in a grammatical valid word?
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Location
    cornwall, England
    Posts
    110

    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

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    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.


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2001
    Location
    cornwall, England
    Posts
    110

    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

  6. #6
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    The Netherlands
    Posts
    403
    private sub txtbox_KeyUp(Keycode as integer, Shift as integer)
    If keycode = vbkeyreturn then
    'checkforvalidword
    end if
    end sub
    There are 10 types of people, those who understand binary and those who don't

    http://merlijn.beyonix.net

  7. #7
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    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.


  8. #8
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    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

  9. #9
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    You guys like to complicate stuff, don't you?

    Try this:

    VB Code:
    1. 'When someone presses the button to see if it's right
    2. Private Sub cmdSeeIfItsRight_Click()
    3.     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
    4.         MsgBox "You got it right!!!"
    5.     Else
    6.         MsgBox "WRONG! Try again."
    7.     End If
    8. End Sub

    Just add as many textboxes as you need
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  10. #10
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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
  •  



Click Here to Expand Forum to Full Width