473,471 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP comparison question...

K
hi guys,
I am doing this here:

dim i
dim j

i = 10
j = 10

If i = j then

But it is giving me a false result...

Any ways to do this comparison so it gives me the proprer result?

Thanx.


Jul 19 '05 #1
3 4686
Are you sure this is all there is to it? Just that code alone should return
true, but if you're assinging i and j by some other means, it's likely that
one of them is a string and one is an integer, or something along those
lines. Doing this will take care of it though:

If CInt(i) = CInt(j) Then...
Depending on what kind of values you're using, you may want CLng to avoid an
overflow, i.e.
i = 32938493
j = 32938493

If CInt(i) = CInt(j) Then
'''Will cause an overflow
http://msdn.microsoft.com/library/de...svariables.asp

Ray at work
"K" <n_***@videotron.ca> wrote in message
news:Mb*******************@wagner.videotron.net...
hi guys,
I am doing this here:

dim i
dim j

i = 10
j = 10

If i = j then

But it is giving me a false result...

Any ways to do this comparison so it gives me the proprer result?

Thanx.

Jul 19 '05 #2
K wrote:
hi guys,
I am doing this here:

dim i
dim j

i = 10
j = 10

If i = j then

But it is giving me a false result...

Any ways to do this comparison so it gives me the proprer result?

Thanx.

Well, I can't reproduce your error.

This:
dim i
dim j

i = 10
j = 10

If i = j then
Response.Write "Equal"
else
Response.Write "Not Equal"
end if
Response.End

gives this result:
Equal

Suggestion: force both variable to the same data subtype:
i=cint(10)
j=cint(10)

HTH,
Bob Barrows
Jul 19 '05 #3
K
I am actually doi ng this:
i = request.form("var1")
j = request.form("var2")

And later, I do;

If i = j then
response.write
Else
response.write
End If

when I try =" or ,+, one return true, the other one false.
So I guess it is comparing the value in itself and not what it holds.

If I do Cint(j) I will get the actual value of the letter won't I?

Thx.

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:uS**************@tk2msftngp13.phx.gbl...
Are you sure this is all there is to it? Just that code alone should return true, but if you're assinging i and j by some other means, it's likely that one of them is a string and one is an integer, or something along those
lines. Doing this will take care of it though:

If CInt(i) = CInt(j) Then...
Depending on what kind of values you're using, you may want CLng to avoid an overflow, i.e.
i = 32938493
j = 32938493

If CInt(i) = CInt(j) Then
'''Will cause an overflow
http://msdn.microsoft.com/library/de...us/script56/ht
ml/vbsvariables.asp
Ray at work
"K" <n_***@videotron.ca> wrote in message
news:Mb*******************@wagner.videotron.net...
hi guys,
I am doing this here:

dim i
dim j

i = 10
j = 10

If i = j then

But it is giving me a false result...

Any ways to do this comparison so it gives me the proprer result?

Thanx.


Jul 19 '05 #4

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

Similar topics

29
by: Steven D'Aprano | last post by:
Playing around with comparisons of functions (don't ask), I discovered an interesting bit of unintuitive behaviour: >>> (lambda y: y) < (lambda y: y) False Do the comparison again and things...
46
by: yadurajj | last post by:
Hello i am newbie trying to learn C..I need to know about string comparisons in C, without using a library function,...recently I was asked this in an interview..I can write a small program but I...
5
by: BILL | last post by:
Hi Everyone, I've been looking through these .NET groups and can't find the exact answer I want, so I'm asking. Can someone let me know the best way (you feel) to search a C# string for an...
37
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
2
by: eastern_strider | last post by:
I'm running into problems about defining a comparison function for a map which has a user defined key. For example: class Key { public: string name; int number; Key (na, nu) : name (na),...
0
by: SvenMathijssen | last post by:
Hi, I've been wrestling with a problem for some time that ought to be fairly simple, but turns out to be very difficult for me to solve. Maybe someone here knows the answer. What I try to do is...
3
by: =?Utf-8?B?R0I=?= | last post by:
I have created a small program that illustrates the problem. I would know how to address the fields that I want to sort on in the greaterThan comparison. Anybody who knows?? using System; ...
37
by: Michele Simionato | last post by:
At work we are shopping for a Web framework, so I have been looking at the available options on the current market. In particular I have looked at Paste and Pylons and I have written my...
5
by: evanevankan2 | last post by:
I have a question about the warning 'comparison between signed and unsigned' I get from my code. It comes from the conditional in the outer for loop. I understand the warning, but I'm not sure...
2
by: puzzlecracker | last post by:
Unlike C++, in Csharp you're only allowed to compare a generic type T with null, if the method it's passed in not implementing IComparable<Tor , IEquatable<T(still don't know why we need these...
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
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,...
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.