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

does array hold a value?

Status
Not open for further replies.

cjkenworthy

Programmer
Sep 13, 2002
237
GB
I have an array which hold some values:

myarray(True, True, False, True, False)

What code would I use to return a value eg. 1 if the array holds a 'True'? or output a message if the array holds a 'True' using VBscript?

cheers,

Chris

 
I'm sure someone can do better but this seems to work.

dim myarray(3), result
myarray(0) = "test"
myarray(1) = "false"
myarray(2) = "false"
result = "0"
for i = 0 to Ubound(myarray) - 1
If myarray(i) = "True" then
result = "1"
End If
next
If result = "1" then
msgbox result & " True found"
Else
msgbox result & " True NOT found!!!"
End If

Regards
Steve Friday
 
If you changed one of the array values to True it would work of course, it might be worth doing

IF Ucase(myarray(i)) = "TRUE" then

just so that you catch any variation of True TRUE TRUe TRue

Regards
Steve Friday
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top