IF .... THEN problems

# Thread: IF .... THEN problems

1. Senior Member
Join Date
Dec 1969
Posts
1,156

## IF .... THEN problems

A quick query about IF ... THEN statements:<BR><BR>What I want to do is to select the cost of postage depending on the cost of the order. So if it is less that £100 postage is £4, if beteeen 100 and 200 postage is 4.50, etc, etc.<BR><BR>I do not know how to change the If ... THEN statement to include this &#039;between x and y&#039; statement.<BR><BR>Any help ? Code is below:<BR><BR>IF del_country = "uk" THEN<BR> &#039;calculate uk postage<BR> IF orderTotal &#060;= 100.00 THEN<BR> postage = 4<BR> END IF<BR> IF orderTotal &#062; 100 AND &#060; 200 THEN<BR> postage = 4.5<BR> END IF<BR> IF orderTotal &#062; 200 AND &#060; 300 THEN<BR> postage = 5<BR> END IF<BR> IF orderTotal &#062; 300 THEN<BR> postage = 5.5 <BR> END IF<BR> ELSE<BR>ETC,<BR>ETC ...<BR><BR><BR><BR>

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

## RE: IF .... THEN problems

IF orderTotal &#062; 100 AND orderTotal &#060; 200 THEN<BR>postage = 4.5<BR>END IF<BR>IF orderTotal &#062; 200 AND orderTotal &#060; 300 THEN<BR>postage = 5<BR>

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

## You *must* repeat the variable...

If orderTotal &#062; 100 AND orderTotal &#060; 200 Then<BR><BR>But that&#039;s still not QUITE right.<BR><BR>But if the order is *exactly* 200 or 300, then you won&#039;t charge anything for the postage, will you?<BR><BR>If you want the postage to change to the next level at 200 and 300, then you need to do<BR><BR>If orderTotal &#062;= 200 AND orderTotal &#060; 300 Then<BR><BR>If you want to charge the lower rate for exactly 200 and 300, then use<BR><BR>If orderTotal &#062; 100 AND orderTotal &#060;= 200 Then<BR><BR>I&#039;ll assume the former choice, simce you use &#060;= 100 in the first test.<BR><BR>IF del_country = "uk" THEN<BR>&nbsp; &nbsp; &#039;calculate uk postage<BR>&nbsp; &nbsp; IF orderTotal &#060;= 100.00 THEN<BR>&nbsp; &nbsp; &nbsp; &nbsp; postage = 4<BR>&nbsp; &nbsp; ElseIf orderTotal &#062; 100 AND orderTotal &#060;= 200 THEN<BR>&nbsp; &nbsp; &nbsp; &nbsp; postage = 4.5<BR>&nbsp; &nbsp; ElseIf orderTotal &#062; 200 AND orderTotal &#060;= 300 THEN<BR>&nbsp; &nbsp; &nbsp; &nbsp; postage = 5<BR>&nbsp; &nbsp; ElseIf orderTotal &#062; 300 THEN<BR>&nbsp; &nbsp; &nbsp; &nbsp; postage = 5.5 <BR>&nbsp; &nbsp; END IF<BR>ELSE<BR>&nbsp; &nbsp; ETC,<BR>End If<BR><BR>Notice that I also used ElseIf (with NO SPACE between ELSE and IF!) to both shorten the code and improve the performance just a bit.<BR><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
•