case sensitive / insensitive string equality

Discussion in 'ASP General' started by Stephanie, Oct 3, 2005.

  1. Stephanie

    Stephanie Guest

    I am working in about 4 different languages these days, and my command of
    ASP is lessening. I *thought* that string equality was case insensitive.

    If I had sType = "MARK"

    and later

    If sType = "Mark"

    I would have expected that to return true. I am enhancing a page written by
    someone else. A whole lot of stuff on the page is referencing the proper
    case where the value is upper case. I need to understand the expected
    behavior before I run off and get a requirements check on how this is
    supposed to work.

    So is my memory incorrect?

    Thanks.
     
    Stephanie, Oct 3, 2005
    #1
    1. Advertisements

  2. Stephanie

    Steven Burn Guest

    If you mean, does "MARK" = "Mark" then no, it will return false. You would
    need to LCase or UCase the values before comparing them. E.g.

    <%
    sString = "MARK"
    '// Pre-case check
    Select Case LCase(sString) '// Or use UCase()
    Case "mark": Response.Write "Value passed was: " & sString & "<br>"
    Case Else: Response.Write "Value passed [ " & sString & " ] was <> mark"
    & "<br>"
    End Select
    '// No case check
    Select Case LCase(sString)
    Case "mark": Response.Write "Value passed was: " & sString & "<br>"
    Case Else: Response.Write "Value passed [ " & sString & " ] was <> mark"
    & "<br>"
    End Select
    %>

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!
     
    Steven Burn, Oct 3, 2005
    #2
    1. Advertisements

  3. Stephanie

    Steven Burn Guest

    Woops, forgot to remove the LCase() from the second select before sending
    :eek:\

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!
     
    Steven Burn, Oct 3, 2005
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.