Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to ignore case when comparing 2 strings??

541 views
Skip to first unread message

Steve K

unread,
Jun 29, 2001, 7:30:01 PM6/29/01
to
Hi all,

I have done a bit of looking, but can't seem to find a way
to easily tell VBS to ignore the case of a string. For
example

I am comparing user defined strings with database records
and looking for a match. So if the DB record has 'Car' and
the user enters 'car' it will fail. My code for this looks
like this:

if U(1) = UserString then
'stuff

Where U(1) is a field in a record and UserString is the
value that the user supplied.

I am hoping to find a tool like this:
if U(1) = IgnoreCase(UserString) then
'stuff

Is there such a function? Sorry if this is obvious,
everything I found dealt with the RegExp object and I
don't want to use that for such a simple task.

Thanks in advance!

Steve

Michael Harris

unread,
Jun 29, 2001, 7:39:51 PM6/29/01
to
Just normalize the case

if ucase(strA) = ucase(strB) then
...

or use the StrComp() function...

StrComp Function
http://msdn.microsoft.com/scripting/vbscript/doc/vsfctStrComp.htm

--
Michael Harris
Microsoft.MVP.Scripting
--
mik...@mvps.org
Please do not email questions - post them to the newsgroup instead.
--

"Steve K" <r...@k2dis.com> wrote in message news:06e801c100f3$6aee9c80$b1e62ecf@tkmsftngxa04...

Steve Klett

unread,
Jun 29, 2001, 7:56:10 PM6/29/01
to
Michael, thanks!

I was being lazy, if I had given it erious thought I would have thought to normalize. Thanks again and sorry for asking such a simple question, this is a good resource so I don't want to get marked as one of those guys that comes along and asks really dumb questions. ;)

Everything works great now-

Steve

PS> Have a good weekend

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Paul Scott

unread,
Jul 1, 2001, 3:54:44 AM7/1/01
to
Steve,
instead of ignoring case you could set it all to upper case.
e.g.

if UCase(U(1)) = UCase(UserString )

Paul


"Steve K" <r...@k2dis.com> wrote in message
news:06e801c100f3$6aee9c80$b1e62ecf@tkmsftngxa04...

0 new messages