Results 1 to 5 of 5

Thread: CaSe InSeNsItIvE?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Talking

    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?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    do this:

    Code:
    If UCase$(text1.text) = "CHRIS" then
      form2.show
      unload me
    end if
    -Shickadance

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can convert to upper case no matter what:
    Code:
    If Ucase(Text1.Text) = "CHRIS" Then
        Form2.Show
        Unload Me
    End If

  4. #4
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Wink

    You could also use the StrComp method:
    Code:
       If StrComp(Text1.Text, "chris", vbTextCompare) = 0 Then
          Form2.Show
          Unload Me
       End If

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    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.)
    -Shickadance

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