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!

Array Question

Status
Not open for further replies.
May 31, 2007
31
AE
Dear All,

I am creating a web front end that takes form input from a user and writes it to a text file. there are two forms. on the second page i have 4 form fields,

Ordered | Received | Description | Price | Total

What i am trying to do is on each submit by the user, write the values to a array. once i have collected all the info, i then write it to a text file (which i know).

should they wish to see the items entered, the user clicks a button and the array is outputted to screen.

How do i get the above to write to a array? Apologies if this is a basic question...

Thanks in advance

 
The normal method for looping through an array is a FOR/NEXT loop. In VBScript it could look like this:[tt]
FOR x = 0 TO 4
Response.Write "Value #" & x & " is equal to " & MyArray(x)
Response.Write "<br>" & vbCrLf
NEXT
[/tt]

In the above example, you know in advance that you have 5 elements in the array and the indexes run from 0 to 4. If you do not know the length of the array, you can use the UBound() function to discover the last index. If you do not know if the starting index is 0 or 1 or some other number then you can use the LBound() function to discover this.

Sometimes you know neither the start nor the end and you end up with something like this:[tt]
FOR x = LBound(MyArray) TO UBound(MyArray)
Response.Write "Value #" & x & " is equal to " & MyArray(x)
Response.Write "<br>" & vbCrLf
NEXT
[/tt]




You can use the FileSystemObject to manipulate the text file. This link will help:
 
Hi Sheco,

thanks for the help. I search on google and i have modified the code a bit. this is what i have

%><table border="1"> <tr><%
Dim myArray
Dim I
MyArray = split(mystr,"|")
For I=0 to Ubound(MyArray)
%><td><%
Response.write MyArray(I)
%></td><%
Next
%></tr></table><%

how do i loop through the code to keep adding entries to the array.

Regards
 
The code we've looked at so far reads values out of an existing array and prints them to the screen.

If you want to increase the size of an array then perhaps the ReDim statement will be the answer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top