If I have a array like this:
[VBS]
Dim iArray
iArray = Array("One","Two","Three","Four")
[/VBS]
How do I find out if the array contains one or more of them variable (eg. one, two, three or four)
| SitePoint Sponsor |

If I have a array like this:
[VBS]
Dim iArray
iArray = Array("One","Two","Three","Four")
[/VBS]
How do I find out if the array contains one or more of them variable (eg. one, two, three or four)





EDIT: Thanks to Dave for pointing out my sloppy cut/paste mistake.Code:found = false for i = 0 to ubound(iArray) if iArray(i) = value then found = true end if next![]()
Last edited by crowdozer; Sep 17, 2002 at 07:50.
-- JIM BOLLA
Wanna play Halo 2? My XBOX Live gamertag: crowdozer

Not quite. Code should be...Originally posted by crowdozer
Code:found = false for i = 0 to ubound(iArray) if ubound(iArray) = value then found = true end if next
Or if you're only looking for the existance of one value (ie, don't care how many) then use....Code:found = false for i = 0 to ubound(iArray) if iArray(i) = value then ' This was the line in error... found = true end if next
Code:found = false for i = 0 to ubound(iArray) if iArray(i) = value then found = true exit for ' prevents searching the whole array... end if next

What I have got is a Select box that you can select Multiple values (Ctrl +Click)
I want the variables in the database to highlight the options in the select box eg:
Datebase field: "One, Three" ( I use the split to sperate the variables)
The Page: The select box has one, two, three or four so when the page loads the database comes form the database it only selects One and Two from the select box.
If you know what I mean.

Thanks Dave got it worked out here is the code to what I was tring to do if anyone else if is looking to do something like this.
[VBS]
<%
Dim iVar, Secs
Secs = Array("Gamer","Business","Security")
iVar = "Security, Business"
sArray = split(iVar, ",")
%>
<SELECT size=3 MULTIPLE>
<%
Sub Options
for each thing in Secs
Response.Write "<Option value=""" & thing & """"
for each x in sArray
x = trim(x)
if x = thing then
Response.Write " SELECTED"
end if
next
Response.Write ">" & thing & vbCrlf
next
End Sub
options
%>
</SELECT>
[/VBS]
Bookmarks