wrote:
> I am not entirely sure, but after scanning the web believe I need to
> use multi-dimensional arrays for my problem - although I have not seen
> any examples of what I am trying to achieve.
>
> I have a form with one field, for which a user will submit a lump of
> delimited data. The data will always be in the same format, ie. 5
> fields per record, each field has a delimeter and a new row starts a
> new record.
>
> for example:
> field1record1 , field2record1 , field3record1 , field4record1 ,
> field5record1
> field1record2 , field2record2 , field3record2 , field4record2 ,
> field5record2
> .....
>
> There are an unknown number of records on submission.
>
> As I know the number of fields per record (5) can I determine the
> number of records by using ubound(myarray) / 5?
No. Have you tried it?
>
> I ultimately want to loop through each field of each record and so I
> can update the database. I have read about:
> - using the split function to seperate the 5 fields
> - determining the number of records using ubound function
> - creating multi-dimension arrays
No, you do not need multi-dimension arrays. You need to loop through the
array (call it records if you wish) created by splitting the raw data on
whatever character(s) is being used to cause the new lines: it could be
"<br>", vbcrlf, vbcr, or vblf. We have no way of knowing given what you
showed us above. You will have to discover it on your own. Anyways, adding 1
to the ubound of THIS array will tell you the number of records.
dim records, fields, newline, record, field
newline="whatever_character_causes_the_line_ breaks_ in_the_data"
records=split(request.form("data"), newline)
for record = 0 to ubound(records)
fields=split(records(record), ",")
if ubound(fields) <> 4 then
'either too few or too many commas
'up to you - quit now or move to next record
else
'loop through fields to pass data to db
end if
next
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"