Results 1 to 7 of 7

Thread: LoWeR CaSe

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    208

    Thumbs down

    I want to compare 2 string..
    But if the string have uppercase un , that doesn't work..
    exemple:
    String1 to compare : welcome
    String2 founded : Welcome

    Code:
    if String1 = String2 then
       'allright
    else
       'nope
    end if
    how can I put the string2 and the string1 in lowercase ?




  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    If Lcase(String1) = LCase(Sting2) Then...
    'Will get them both in LowerCase
    
    'Use UCase(String) for Uppercase
    Hope it helped mate!

    [Edited by Jop on 09-09-2000 at 11:05 AM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'you can also just use the string compare function
    
     Dim x As String, y As String
        Dim myComp As String
        
        x = "hello"
        y = "HeLlO"
    'if you use 1 as the 3rd argument it forces a text comparison
    
        myComp = StrComp(x, y, 1)   ' Returns 0 if matched.
        
        If myComp = 0 Then
            MsgBox myComp
        End If
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Guest
    something else you should know, put this in your declarations section...

    OPTION COMPARE TEXT

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Let's be fair and keep it easy...

    ...wich one is faster? my code is shorter
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    myComp = StrComp(x, y, 1) ' Returns 0 if matched

    not shorter that the line I gave if I didn't include the sample and besides we are not in a competition. we are supplying different avenues for the questioner to explore and learn.

    The Option Explict is forced when the user enters the 3rd option 1 in the strCompare function.



    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  7. #7
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    and besides we are not in a competition. we are supplying different avenues for the questioner to explore and learn.
    I'm sorry if I made the impression to being competitive, maybe it was a kinda useless post, but I didn't see why we should use that code if you could do it in 1 line, but you're right, we should hive the questioners different solutions for their problem to let them deside to use what code to use.

    Again, I'm sorry to make such a stupid reply, it wasn't meant to challenge you in any way.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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