# ASP comparison question... - ASP

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

1. ## ASP comparison question...

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.

K Guest

2. ## Re: ASP comparison question...

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
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vbsvariables.asp[/url]

Ray at work

"K" <n_komvideotron.ca> wrote in message
news:MbtWa.14679\$Sn.185155wagner.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.
>
>
>
>

Ray at Guest

3. ## Re: ASP comparison question...

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

Bob Barrows Guest

4. ## Re: ASP comparison question...

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:uSB6fsCWDHA.2476tk2msftngp13.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
>
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/ht[/url]
ml/vbsvariables.asp
>
> Ray at work
>
>
> "K" <n_komvideotron.ca> wrote in message
> news:MbtWa.14679\$Sn.185155wagner.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.
> >
> >
> >
> >
>
>

K Guest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•