Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Multi-dimensional arrays - (I think!)

Reply
Thread Tools

Multi-dimensional arrays - (I think!)

 
 
ben.r.wood@gmail.com
Guest
Posts: n/a
 
      08-23-2007
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?

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

but I am not sure how to put them together. Any direction would be
appreciated

 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      08-23-2007
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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?
>
> 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
>
> but I am not sure how to put them together. Any direction would be
> appreciated
>


Split by vbCrLf first. This gives you an array of strings containing each
record.

Loop the array and on each iteration split each element into another array
(based on your field delimiter) that you can use update your DB.



--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-23-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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"


 
Reply With Quote
 
ben.r.wood@gmail.com
Guest
Posts: n/a
 
      08-23-2007
thanks guys - that was just the info I needed. Got it working fine
now!




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
char arrays and integer arrays... why the difference? Bill Reyn C++ 3 06-22-2004 12:01 PM
Arrays.asList() returning java.util.Arrays$ArrayList Alexandra Stehman Java 5 06-17-2004 06:04 PM
Arrays and Pointers to Arrays kelvSYC C Programming 2 09-26-2003 06:52 AM
initializing arrays of arrays Mantorok Redgormor C Programming 4 09-11-2003 02:08 AM



Advertisments