If and AND statements

# Thread: If and AND statements

1. Senior Member
Join Date
Dec 1969
Posts
151

## If and AND statements

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

2. Senior Member
Join Date
Dec 1969
Posts
259

## RE: If and AND statements

The syntax of the AND looks correct.<BR><BR>1. Instead of "else" I would "end if"<BR>You&#039;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

3. Senior Member
Join Date
Dec 1969
Posts
151

## 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.

4. Senior Member
Join Date
Dec 1969
Posts
723

## 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&#039;m assuming you&#039;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>

5. Senior Member
Join Date
Dec 1969
Posts
151

## RE: If and AND statements

thank you and yes i took the comments out..i&#039;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
•