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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

some Array/Looping help 1

Status
Not open for further replies.

biscuit1

Programmer
Apr 4, 2002
15
0
0
US
I have an Array that I'm using to loop through some form fields. I need to test that there is something in at least one of the fields. The way I have thing right now, the loop stops as soon as it finds any empty field. I need it to check them all. Thanks for any help.

Dim myArray(15)
myArray(0) = old_1st
myArray(1) = old_2nd
myArray(2) = old_3rd
myArray(3) = old_4th
myArray(4) = new_1st
myArray(5) = new_2nd
myArray(6) = new_3rd
myArray(7) = new_4th
myArray(8) = benefits_1st
myArray(9) = benefits_2nd
myArray(10) = benefits_3rd
myArray(11) = benefits_4th
myArray(12) = cost_1st
myArray(13) = cost_2nd
myArray(14) = cost_3rd
myArray(15) = cost_4th

Sub describe()
For i = 0 TO 15
If(myArray(i) = "") Then
ErrorMsgText.Value = "Please enter some descriptions"
errorFlag.Value = "9"
NEXT_FORM.Value = "einstein_award_nomination.xft"
PREFERENCE.Value = "auto"
ACTION.Value = "0"
Exit Sub
End If
Next
End Sub
 
It looks to me like the exit sub is what's causing the thing to finish after the first instance of an empty element.

Sub describe()
For i = 0 TO 15
If(myArray(i) = "") Then
ErrorMsgText.Value = "Please enter some descriptions"
errorFlag.Value = "9"
NEXT_FORM.Value = "einstein_award_nomination.xft"
PREFERENCE.Value = "auto"
ACTION.Value = "0"
Exit Sub
End If
Next
End Sub
 
I commented out the Exit Sub and no luck. I need something like "If(myArray(check every element) = "") Then ..."
 
Maybe something like this?

blnAllBlank = True
For i = 0 to 15
If myArray(i) <> &quot;&quot; Then
blnAllBlank = False
End If
Next

If blnAllBlank = True Then
ErrorMsgText.Value = &quot;Please enter some descriptions&quot;
errorFlag.Value = &quot;9&quot;
NEXT_FORM.Value = &quot;einstein_award_nomination.xft&quot;
PREFERENCE.Value = &quot;auto&quot;
ACTION.Value = &quot;0&quot;
End If

 
You did it!!!!! Tom thanks for your help. I should have seen this one. I must have been looking in wrong direction.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top