
If and AND statements
I can't seem to get my if statements to work (this is my first time using AND...<BR><BR>'If (ors("Month1") <> "") AND (ors("Month2") <> "") AND (ors("Month3") <> "") AND (ors("Month4") <> "") AND (ors("Month5") <> "") Then<BR> 'j = 4<BR> 'Else <BR><BR>'If (ors("Month1") <> "" ) AND (ors("Month2") <> "")AND (ors("Month3") <> "") AND (ors("Month4") <> "") Then <BR> 'j = 3<BR> ' Else<BR> 'If (ors("Month1") <> "") AND (ors("Month2") = "") AND (ors ("Month3") <> "") Then <BR> 'j = 2<BR> 'Else <BR> 'If (ors("Month1") <> "") AND (ors("Month2") <> "") Then<BR> 'j = 1<BR> 'Else<BR> ' j = 0<BR> 'End If<BR> 'End If<BR> 'End If

RE: If and AND statements
The syntax of the AND looks correct.<BR><BR>1. Instead of "else" I would "end if"<BR>You'd be saying if this is true then do this, otherwise do nothing and move on.<BR>2. Someone will probably comment about using this many if/thens<BR>3. Is there a reason they are all commented out?<BR><BR>Andy

RE: If and AND statements
I used end if also but same results, the comments came form my program (I comment out the code to run my program without the statements), i just cut and paste with the comments on the in here. Also, sometimes pasting vbscript without comments will cause this messageboard to crash.

RE: If and AND statements
You only need one "end if" and change "Else If" to "Elseif".<BR><BR>Are you getting a particular error?<BR><BR>*I'm assuming you've tried it uncommented?<BR><BR>You can also do some rearrangement like this,<BR><BR>function notEmpty(arData)<BR>Dim i<BR>Dim data<BR><BR>if isarray(arData) then<BR>for i = 0 to ubound(arData)<BR>data = data + arData(i)<BR>next<BR>end if<BR><BR>if len(data) = 0 then<BR>notEmpty = false<BR>else<BR>notEmpty = true<BR>end if<BR>end function<BR><BR>month1 = ""<BR>month2 = ""<BR>month3 = ""<BR>month4 = ""<BR>month5 = " "<BR><BR>if notEmpty(Array(month1,month2,month3,month4,month5) ) then<BR>j=4<BR>elseif notEmpty(Array(month1,month2,month3,month4)) then <BR>j=3<BR>elseif notEmpty(Array(month1,month2,month3)) then <BR>j=2<BR>elseif notEmpty(Array(month1,month2)) then <BR>j=1<BR>else <BR>j=0<BR>end if<BR>

RE: If and AND statements
thank you and yes i took the comments out..i'm going to try it.
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

