473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how do you compare two strings

Hi,

I was wondering how do you compare variables that contain text strings in
ASP.

When I use the following If.. Then statement:

If Rs("StyleNo") <> arrStyleNo(aCount) Then
I always get the following error when I try to browse the page:

Error Type:
(0x80020009)
Exception occurred.
Thanks.

Peter
Jul 19 '05 #1
2 13854
Try:

If CStr(Rs.Fields.Item("StyleNo").Value) = CStr(arrStyleNo(aCount))

The CStr may be overkill, depending on what's in your array.

But to answer your subject line, the StrComp function is what is used in VB
Script for comparing two strings.
http://msdn.microsoft.com/library/en...fctstrcomp.asp

Ray at home
"Peter" <pe***@visors.com.hk> wrote in message
news:bk*********@imsp212.netvigator.com...
I was wondering how do you compare variables that contain text strings in
ASP.

When I use the following If.. Then statement:

If Rs("StyleNo") <> arrStyleNo(aCount) Then
I always get the following error when I try to browse the page:

Error Type:
(0x80020009)
Exception occurred.

Jul 19 '05 #2
Since you said you want to compare text, instead of this:
If Rs("StyleNo") <> (arrStyleNo(aCount) Then

How about this:
If Rs("StyleNo") <> CStr(arrStyleNo(aCount)) Then

Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: J.W. | last post by:
How do I compare strings in javascript? The "==" double equals or "!=" doesn't seem to work in this case. I'm sure string comparison has been explained before but searching Google didn't find...
1
by: al | last post by:
To compare two strings, not just to see if they are "equal" ("abcd"="abcd") but tell their alphabetical order: string a, b; a = "abcd"; b = "bbcd"; Can all the ways below to do such...
3
by: Drew | last post by:
Hello - I am a converted VB programmer. What I am trying to do it compare two strings in an if statement. The problem is that when I use string.compare it always returns a negative 1. I have...
14
by: Samuel R. Neff | last post by:
Why would you cast two strings to objects to compare them? I saw code in an MS sample on MSDN and don't get it. if ( (object)name == (object)attr.name ) { both "name" and "attr.name" are...
3
by: Jim Carlock | last post by:
I'm creating a lot of arrays. Some of the arrays carry words that get duplicated... For example: $aCities = {"Durham", "Raleigh", "Raleigh-Durham", "Salem", "Winston", "Winston-Salem" } I've...
0
by: Diego Martins | last post by:
Hi! The following code snippet: namespace { bool charCompare(char a, char b) { return tolower(a) < tolower(b); } } bool compareString(const std::string & s1, const std::string & s2) {
1
by: lawrence k | last post by:
Can I check alphabeticallness as easily as "aaa" "bgeoid" ? $var1 = "cccccc"; $var2 = "f"; if ($var1 $var2) {
2
by: jonathan184 | last post by:
Hi I am trying to use if statements to search strings on each line and if it finds matches to the string write to a variable and then echo variable and the loop starts again. The match is being...
6
by: shapper | last post by:
Hello, I want to compare two strings in a Linq Query. In this case "Car", "cAr", "CAR" would all be the same. Should I use ==, equals, ... ? What is the best way to do this?
2
by: Thenu | last post by:
Im doing my project in Asp .net with Vb .net Coding.... I have some Problem in doing my project... If anybody Guide me means it would be great pleasure for me.. I want to compare the strings.Its...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.