case sensitive / insensitive string equality

S

Stephanie

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.
 
S

Steven Burn

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!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top