Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use a complex range in a complex IF statement

Status
Not open for further replies.

novice2

Technical User
Jul 25, 2001
1
US
I have a range to be used in the first IF statement
assetnum between 85000 and 85999
assetnum between 88000 and 88900
and assetnum = 87500

if these above ranges occur then the 2nd IF statement

if(RS("Expense").value){
Response.Write(rightAlign(setDecimals(RS("ActExp").value.toString(), 0), "na") + " ");

would display "na".

if the above ranges does not occur then the statement

if(RS("Expense").value){
Response.Write(rightAlign(setDecimals(RS("ActExp").value.toString(), 0), colAct) + " ");
would display the actual value of the expense.

The code as mentioned below works fine for only one number. please help me with this nightmare. Thanks.

Actual code

if(RS("AssetNum").value != "87500"){

if(RS("Expense").value){
Response.Write(rightAlign(setDecimals(RS("ActExp").value.toString(), 0), colAct) + " ");
Response.Write(rightAlign(setDecimals(RS("PLExp").value.toString(), 0), colPlan) + " ");
}else{
Response.Write(rightAlign("" + setDecimals(RS("ActUnits").value.toString(), 0), colAct) + " ");
Response.Write(rightAlign("" + setDecimals(RS("PLUnits").value.toString(), 0), colPlan) + " ");
}
}else{
if(RS("Expense").value) {
Response.Write(rightAlign(setDecimals(RS("ActExp").value.toString(), 0), "na") + " ");
Response.Write(rightAlign(setDecimals(RS("PLExp").value.toString(), 0), "na") + " ");
}else{
Response.Write(rightAlign("" + setDecimals(RS("ActUnits").value.toString(), 0), "na") + " ");
Response.Write(rightAlign("" + setDecimals(RS("PLUnits").value.toString(), 0), "na") + " ");
}
}
 
Wouldn't it be (if all conditions were and):

if((RS(&quot;AssetNum&quot;).value = &quot;87500&quot;) && (RS(&quot;AssetNum&quot;).value >= &quot;88800&quot; && RS(&quot;AssetNum&quot;).value <= &quot;88900&quot;) && (RS(&quot;AssetNum&quot;).value >= &quot;85000&quot; && RS(&quot;AssetNum&quot;).value <= &quot;85999&quot;)){

//do stuff

} gettin' jiggy wid' it --
smbure
 
Actually...they need to be OR, sorry

if((RS(&quot;AssetNum&quot;).value = &quot;87500&quot;) || (RS(&quot;AssetNum&quot;).value >= &quot;88800&quot; && RS(&quot;AssetNum&quot;).value <= &quot;88900&quot;) || (RS(&quot;AssetNum&quot;).value >= &quot;85000&quot; && RS(&quot;AssetNum&quot;).value <= &quot;85999&quot;)){

//do stuff

} gettin' jiggy wid' it --
smbure
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top