As long as I'm at it...Here's another quick and easy one for you. I have some arrays that are not dynamic (I create them like this: Dim myArray(5)) and then populate them based on form results.
Question: Is there a way to tell how many of the indexes in myArray have a value? such as myArray.count? right now I'm looping through and checking to see if the value is null, but I have a feeling there is a better way. Thanks again, Ricki -----Original Message----- From: Michael Elfial [mailto:[EMAIL PROTECTED]] Sent: Monday, September 02, 2002 1:51 PM To: ActiveServerPages Subject: RE: convert string to array Hi Ricki, I have a minute so why not answer in short. I'll explain two ways: Split function: arr = Split(a_string,",") Will split the string into array using the specified delimiter. But I think this is not good way to deal with the multiply choices listboxes. Using the strings collection: If your listbox is like this <SELECT NAME="MyLB">.... Then you will ceive in the Request("MyLB") all the selected values. In fact they are in a collection that can be looped as an array and the comma delimited result is returned only as an alternative. So you can do these things x = Request("MyLB").Count will return the number of the values (the selected values) x = Request("MyLB")(4) will return the 4-th value E.g you can do this For I = 1 To Request("MyLB").Count x = RequesT("MyLB")(I) ' Do something with it Next Or if you prefer enumerations do this For each e in Request("MyLB") ' do something with the e - it contains the value Next I recommend you the second way - the collection because this will save a little memory and in fact acts like an array. Also using split may lead to some mistakes if certain value contains the delimiter in it. This sounds impossible for a listbox but who knows - it is better to use the safest way. Michael -----Original Message----- From: Ricki Williams [mailto:[EMAIL PROTECTED]] Sent: Monday, September 02, 2002 9:37 PM To: ActiveServerPages Subject: convert string to array I know this has to be simple, but I'm not finding the answer and I've never tried it before. I have a list box where they can make multiple selections. A sample return from the box is: African, African - American, Aleutian, American Indian, Asian, Bangladeshi, Bhutanese, Brazilian My question is, how do I loop through this string and change it into an array so I can loop through it for later processing? Or should I even convert it to an array if I can loop through the string just as easily? If that's the case, then I'm still back to - How do I loop through a string? thanks, Ricki --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [EMAIL PROTECTED] To unsubscribe send a blank email to %%email.unsub%% --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
