
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 'between x and y' statement.<BR><BR>Any help ? Code is below:<BR><BR>IF del_country = "uk" THEN<BR> 'calculate uk postage<BR> IF orderTotal <= 100.00 THEN<BR> postage = 4<BR> END IF<BR> IF orderTotal > 100 AND < 200 THEN<BR> postage = 4.5<BR> END IF<BR> IF orderTotal > 200 AND < 300 THEN<BR> postage = 5<BR> END IF<BR> IF orderTotal > 300 THEN<BR> postage = 5.5 <BR> END IF<BR> ELSE<BR>ETC,<BR>ETC ...<BR><BR><BR><BR>

RE: IF .... THEN problems
IF orderTotal > 100 AND orderTotal < 200 THEN<BR>postage = 4.5<BR>END IF<BR>IF orderTotal > 200 AND orderTotal < 300 THEN<BR>postage = 5<BR>

You *must* repeat the variable...
If orderTotal > 100 AND orderTotal < 200 Then<BR><BR>But that's still not QUITE right.<BR><BR>But if the order is *exactly* 200 or 300, then you won'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 >= 200 AND orderTotal < 300 Then<BR><BR>If you want to charge the lower rate for exactly 200 and 300, then use<BR><BR>If orderTotal > 100 AND orderTotal <= 200 Then<BR><BR>I'll assume the former choice, simce you use <= 100 in the first test.<BR><BR>IF del_country = "uk" THEN<BR> 'calculate uk postage<BR> IF orderTotal <= 100.00 THEN<BR> postage = 4<BR> ElseIf orderTotal > 100 AND orderTotal <= 200 THEN<BR> postage = 4.5<BR> ElseIf orderTotal > 200 AND orderTotal <= 300 THEN<BR> postage = 5<BR> ElseIf orderTotal > 300 THEN<BR> postage = 5.5 <BR> END IF<BR>ELSE<BR> 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

Forum Rules

