If x <> y statements

# Thread: If x <> y statements

1. Senior Member
Join Date
Dec 1969
Posts
413

## If x <> y statements

Would writing this...<BR><BR>A = Request.Form("A")<BR>B = Request.Form("B")<BR>C = Request.Form("C")<BR><BR>If A + B &#060;&#062; C Then <BR> Response.Write "Not correct, hit back n do it right"<BR> Response.End<BR>End If<BR><BR>...be like saying...<BR><BR>If A plus B does not equal C then write "Not correct"

2. Senior Member
Join Date
Dec 1969
Posts
1,274

## Yep

Although you MIGHT want to put A+B in parentheses, just to be on the safe side.

3. Senior Member
Join Date
Dec 1969
Posts
413

## So this should work then?

If PayDetails = "Credit Card and Payroll Deduction" Then<BR> If (CCAmt1 + PDAmt1) &#060;&#062; Grandtotal Then<BR> Response.Write "Not Right"<BR> Response.End<BR> End If<BR>End If

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Sure...and could even be simpler...

If PayDetails = "Credit Card and Payroll Deduction" AND (CCAmt1 + PDAmt1) &#060;&#062; Grandtotal Then<BR> Response.Write "Not Right"<BR> Response.End<BR>End If<BR><BR>If you are paranoid ("a little paranoia is healthy for programmers and their programs"), you could do<BR><BR>If ( PayDetails = "Credit Card and Payroll Deduction" ) AND ( (CCAmt1 + PDAmt1) &#060;&#062; Grandtotal ) Then<BR> Response.Write "Not Right"<BR> Response.End<BR>End If<BR>

5. Senior Member
Join Date
Dec 1969
Posts
413

## I'm getting "Not Right" every time

any suggestions?<BR>I did a Response.Write on GrandTotal, CCAmt1, and PDAmt1<BR><BR>GrandTotal (for my example) = 1000<BR>CCAmt1 and PDAmt1 both equaled 500, but i still get "Not right"

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yeah, but did you do...

Response.Write CCAmt1 + PDAmt1<BR>???<BR><BR>Want to be you are getting <BR> 500500<BR>???<BR><BR>If those variables are strings, then the + sign just concatenates them instead of adding the numbers.<BR><BR>Try<BR> CCAmt1 = CDBL( CCAMt1 )<BR> PDAmt1 = CDBL( PDAmt1 )<BR>and *then* see if it works?<BR><BR>

7. Senior Member
Join Date
Dec 1969
Posts
413

## here's the code, "Not right" still everytime

If PayDetails = "Credit Card and Payroll Deduction" Then<BR> CCAmt1 = CDBL(CCAmt1)<BR> PDAmt1 = CDBL(PDAmt1)<BR> If CCAmt1 + PDAmt1 &#060;&#062; GrandTotal Then <BR> Response.Write "Not Right" <BR> Response.End<BR> End If <BR>End If <BR><BR>Is this correct?<BR>

8. Senior Member
Join Date
Dec 1969
Posts
413

I&#039;m leaving for a 3 month sebaticle (sp?) to go back for my 5th and last year of school, play football, and not think about ASP for a few months. <BR><BR>Happy Programming Everyone!!<BR><BR>I&#039;m sure I&#039;ll be full uf useless questions when I return!<BR><BR>Scott

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## Probably off by a tiny amount...

If you are still around, try this:<BR><BR>Response.Write GrandTotal - ( CCAmt1 + PDAmt1 )<BR><BR>You might see an answer like 1.78E-13 or something.<BR><BR>When VBS displays numbers, it rounds them, a little. So if the numbers were really (say)<BR><BR>1000.0000000001<BR>500.0000000003<BR> 499.9999999995<BR><BR>Then they would still display as 1000, 500, 500. But, of course, the calculation of "&#060;&#062;" would say the sum is &#060;&#062; 1000.<BR><BR>

#### Posting Permissions

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