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

Split a String List

Status
Not open for further replies.

joyceda59

Technical User
Apr 3, 2007
29
CA
Hii,

I am pretty new to the asp scripting language and am eager to learn. Currently I am practicing loops and arrays. While reading this tech book, I was asked a question that I am not able to find the answer for.

There is a SQL database that stores information about all the bestsellers in certain year. This database will receive forms from users and store the field information into its table columns accordingly. Now in the form, the user has an option to select which bestseller he/she has read. So the user has the option to select more than one checkboxes(i created tyhe form with my minimal html knowledge :) ). Now all the books that are selected by the user are going to be included into a table column as one string. However, i don't want to store it as a string. Therefore i am trying to split my string and store each book into an array( not sure if i can do that). In order to do this, i am using the split function. My problem is that, im not too sure how to store each of the books selected into the array. I want to try to make this process as dynamic as possible.

Here is what I thought of doing:

strList = Request("books") //stores the book list

bookListArray = Split(strList, "/,")

dim i
for i = 0 to ...//I dont know how to identify the last book that the user selected

bookListArray(i) = ...

Next

Hopefully Im clear enough!

Thxx!
 
Hi and welcome to Tek-Tips. To get the best from these forums please read faq222-2244.

For this question, arrays have a Ubound property. For more details on VBscript see
___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
You can use the ubound command, or you could use the for loop with the each/in clause:

Code:
For Each i in bookListArray

Next

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top