Problem with If statement!

# Thread: Problem with If statement!

1. Charles. Guest

## Problem with If statement!

Hello,<BR><BR>I am trying to use an if statement with two variables received by using Request.Form, by the program doesn&#039;t understand the syntax, can you please help.<BR><BR>x = request.form("value")<BR>y = request.form("cost")<BR><BR>response.write x &#039; value = 5<BR>response .write y &#039; value = 3<BR><BR>if x &#062; y then &#039; this line doesn&#039;t process<BR>statement<BR>end if

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## RE: Problem with If statement!

try this<BR><BR>if clng(x) &#062; clng(y) then<BR>&#039;&#039;&#039;&#039;<BR>end if

3. Senior Member
Join Date
Dec 1969
Posts
758

## RE: Problem with If statement!

use if CInt(x) &#062; CInt(y) Then<BR><BR><BR>jason

4. Senior Member
Join Date
Dec 1969
Posts
699

## RE: Problem with If statement!

ASP has trouble figuring out the datatype of variables on its own. To make your statement work, try:<BR><BR>if cInt(x) &#062; cInt(y) then<BR><BR>That&#039;ll force it to realize that you&#039;re comparing two numbers.

5. Senior Member
Join Date
Dec 1969
Posts
1,431

## the program doesn't understand the syntax

I believe that should read<BR><BR>"the programmmer doesn&#039;t understand the syntax" hehe<BR><BR>ok now on to the serious matter of answering your question. <BR><BR>x and y are both text values as all values passed through the request objectget passed as text. To fix this do<BR><BR>x = cdbl(request.form("value"))<BR>y = cdbl(request.form("cost"))<BR><BR>and all should be well with your if statement

6. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## For Jason and Peter

lose cint from your vocab what if you get a very large number??<BR><BR><BR>try and stick to ONLY clng.<BR><BR>

7. Charles Guest

## RE: the program doesn't understand the syntax

8. Senior Member
Join Date
Dec 1969
Posts
758

## done... CInt??? What's CInt??? hehehe nm

.

#### Posting Permissions

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