473,545 Members | 289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(aCou nt) 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 13880
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.c om.hk> wrote in message
news:bk******** *@imsp212.netvi gator.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(aCou nt) 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(aCo unt) 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
76518
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 any code that looked similar to this one: ----- function CheckPassword(val,val2, str) { var strInput = new String(val.value);
1
2648
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 comparison? 1. a > b
3
3183
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 entered the same string, different strings. The string is loaded from the results from a dataset. The other string is loaded from a textbox....
14
2391
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 declared as string. http://msdn.microsoft.com/XML/BuildingXML/XMLinNETFramework/default.aspx?pull=/library/en-us/dnxmlnet/html/XmlBkMkRead.asp ...
3
2477
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 been using stristr alot but that ends up meaning that I must take the arrays out of alphabetical order and in the end it complicates things on my...
0
2295
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
1498
by: lawrence k | last post by:
Can I check alphabeticallness as easily as "aaa" "bgeoid" ? $var1 = "cccccc"; $var2 = "f"; if ($var1 $var2) {
2
1566
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 found fine but anything under the matched record is getting the same value of the variable when there is no match. I tried if and elseif and i get...
6
17578
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
1870
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 about Disambiguate Doctors profile... If there are four or five members having same name i have to check whether they are same person or not ... ...
0
7465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7416
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
701
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.