Looping Through Tw-dimensional Array

I need to loop through a two-dimesnional array (x,y) until a value in x is empty or the end of the array is reached, whichever comes first. Example array:

Dim myArray(4,1)

myArray(0,0) = "part 1"
myArray(0,1) = quantity
myArray(1,0) = "part 2"
myArray(1,1) = quantity
myArray(2,0) = "part 3"
myArray(2,1) = quantity
myArray(3,0) = ""
myArray(3,1) = quantity
myArray(4,0) = "part 5"
myArray(4,1) = quantity

In the example above, the loop should stop once it determines myArray(3,0) is empty. If myArray(3,0) was not empty, the loop would continue until the end of the array was reached. Anybody have a code example to do this?

View Replies


ADVERTISEMENT

One Dimensional Array

If I have an Array declared like this:

MyArray = array (“value 1”, “value 2”, value 3”)

Will this array physically be a long single row or a single column (like below)?

Value 1 value 2 value 3

Or

Value 1
Value 2
Value 3

View Replies View Related

Two-Dimensional Array Resizing

how do I resize a two-dimensional array? The array I'm working with is "data(X)(Y)" where X is 0 or 1 and Y grows to a dynamic number.If "data(1)(highest element)" IsNull, then I need to strike it from the array. I believe this should be doable by simply resizing the second dimension down by one. Through researching I established the following set of code:

I = UBound(data(0)) - 1
ReDim Preserve data(2,I)

But it results in a "Subscript out of range" message on the latter line. Short of looping through and building a new array.

View Replies View Related

ADODB Versus 2-Dimensional Array

I'm working on developing (yet another) shopping cart for my work. I was wondering if anybody knows which approach leaves a smaller footprint in memory on a server: an ADODB Recordset which stores arrays one-dimensional arrays or a two-dimensional array?

We are currently hosing our web site on a shared machine at Verio. The cart I have to build needs separate carts because a customer's products can come from different locations. Each location will have a different cart. On the cart page itself, I would like to display each cart in a separate location.

Logically, it make the most sense (to me, anyway) to use an ADODB Recordset to manage each individual cart (array) than to write the code to manage the arrays. What are the disadvantages of using ADODB recordset instead of a two-dimensional array in this case?

Which approach would be easier to manage and manipulate? Are there any reasons why I shouldn't use a two-dimensional array? The nice thing about ADODB is that I will not need to program certain features and have access to FILTERS.

Any suggestions about how each approach would scale as site traffic increases? Will one approach bog down the server more than the other? I'm also open to suggestions about a possible, yet illusive, 3rd way.

View Replies View Related

Multi Dimensional Array In Form

what i want to do is have a (multi dimensional?) array, so that each second dimension represnts a row of radiobuttons. The trouble is i don't know what to name the arrays as. Obviously for each row the names for the different radio buttons will be the same, meaning you can only select one.

in php you could do it with a single array as you name each row of radio button differently:

1st row:
name='array[0]'
2nd:
name='array[1]'

in asp it doesn't look like you can do it this way, because to create a similar array you'd do something like
1st row:
name='array'
2nd
name='array'

then use split in the recipient script. This does not work however, because each radiobutton (on all rows) has the same name, and therefore when you click one all the rest on every row are unclicked..

View Replies View Related

Vbscript Mutli Dimensional Array

I understand the logic behind a multi dimensional array (sort of). What I need to do is be able to capture the product information (that is in a product session) that a user has selected and email it to a specific address.

The email coding page is written in javascript. This page is already being used to also send the customer credit information. If anyone has some insight in this I would be very appreciative. Code:

View Replies View Related

Looping Thru Array

I need to look at each element in an array to write it to the web page, one element at a time. The previous page contained a form of dynamically created checkbox sets. The number of checkbox sets will always be unknown. Anyway, here's my question:

I've tried different code (due to circumstances that would be to lengthy to get into here, I need to use vbscript, be able to use javascript within vbscript code.

Here are examples I've tried and the results: Code:

View Replies View Related

Looping And Array Problems

I'm having problems with abit of code i'm playing with to remove html tags from a variable. I just can get it to work as im not sure how to handle the "for" statement to work with the array. Code:

View Replies View Related

How Can I "ReDim" A Two-dimensional Array?

I guess one should declare the array using empty brackets.

Dim MyArray()

Later I set MyArray to:

Redim MyArray(2,3)

The problem comes now. How should I use Redim again? I have heard that only one of the two dimensions can be enlarged or decreased. Is that correct? If so, which dimension would be ok to set to 5 in MyArray. Is ReDim MyArray (2,5) correct or should it be (5,2)?

View Replies View Related

Two Dimensional Arrays

how to get and assign the first dimension of a two dimensional array to another array? For example, I have a recordset object (rsObj) and then I take that object and assign to array (via GetRows() method). I would like to take just the first dimension and assign to another array, but I get a "Subscript Out of Range" error.... any ideas?

temp_array = rsObj.GetRows
new_array = temp_array(0)

View Replies View Related

Storing Dimensional Arrays

Does anyone know how to store multi-dimensional arrays in the Application object? And if so please show an example.

Also, how do you loop through multi-dimensional arrays? I just can't seem to get my head wrapped around this.

View Replies View Related

Various Basic Questions Regarding Two-dimensional Arrays

I would like to know how many rows and columns are created in the following array. Is it 10 rows and 2 columns or is it 10 columns and 2 rows? Dim Array(9,1)

I have searched for some info about it but not found any consensus. Some sources claim that the first number symbolizes the rows and the second number the columns and other sources claim the opposite. I am confused.

What is it really like? How many rows and columns?

Assume that I need an array with 2 columns and 5 rows then how should it be declared (4,1) or (1,4)?

Which is the first dimension and which dimension it the second one? Horizontally (first/second) vs vertically (first/second)?

How are the various elements called, for example how is the element on the first row in the 5th column called. By using (0,4) or (4,0)?

Assume that I want to store first and last names in two separate columns in an array and then expand the array by using Redim/preserve. The dimension I want to expand is the one with the rows because I view the array as a table with two columns.

I know there are certain rules that apply when it comes to using Redim/preserve on multidimensional arrays. Only the last dimension can be changed etc. How could that be done in this case? I am mainly interested in the declaration (1,x) or (x,1), where 1 is the number of columns and x number of rows (that is increased).

View Replies View Related

Creating Multi Dimensional Arrays On The Fly

I am trying to setup a 2 dimensional array which i can populate on the fly with data coming frtom a database.

I understand that you have to set a specfic size for the array in ASP, but I am looking at making the array dynamic and using the Redim function to increase the size by 1 each time. Code:

View Replies View Related

Subscripts And Dynamic Multi-dimensional Arrays

I am trying to create a dynamic multi-dimensional array, based on a count from a database. The count is correct, but when I try to Redim preserve my array, I get an error...

Subscript out of range

referring to the line of code...

ReDim Preserve builderArray(CInt(builderCount),5)

How can I do this redim successfully?

View Replies View Related

ASP Looping

I have a database with many fields. One of this field is of type memo
which contains some bullet points seperated by # sign (something along
those lines). What I have is this code which gives me a table with one
row and as many columns in the split array. Code:

View Replies View Related

Looping With Asp

I am trying to loop through my database to display a picture. That is no problem. Where I hit a snag is this. I only want three pictures then break to a new row and three more, etc. Any ideas? What this does is display one record. Code:

View Replies View Related

Looping

Is it possable to exit a loop in asp.

View Replies View Related

Looping

i got a problem regarding abt several looping running at the same time. I wanted the 1st loop to run once and then the 2nd loop to start running after the 1st loop ran once.. but the coding I do doesn't seem to be able to do that. Can sum1 teach mi how to do it?
The coding:

View Replies View Related

Looping In ASP

I am working on an asp page that goes to a rs to get data. I need to run a loop that pulls the data line by line until it is at the end of the database. I could do an Until loop, but I don't know how many records are in the recordset. So I suppose it should be a do until end-of-file?

View Replies View Related

Looping In ASP

In my arrary ListSong(), I have song names like (Song1.mp3,Song2.mp3,Song3.mp3,.....).

If the user selects more than one song, it should play one after the other. I want to do some looping for the <embed> tag. Here is my code:

<EMBED SRC="Songs/<%=ListSong(0)%>.mp3" VOLUME="50" AUTOSTART="true" HEIGHT="80" WIDTH="415">

View Replies View Related

SQL Looping

is there anyway to do a loop with an sql command in? Ive created a message board type of thing but its got the option to delete unwanted messages. next to each message there is a lil checkbox with the Record ID for the message as the name tag, what im trying to do is when a user clicks say 3 messages to remove it puts the id's of the checkbox's clicked into a query string or something and then loops deleting the messages in the database.sorta works like this

Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("databases/conkers.mdb")
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
messages = request.QueryString("ids")
for each value in messages do
mySQL = "DELETE FROM messages WHERE ID = '" &messages & "'"
Set RS = myConn.Execute(mySQL)
loop

View Replies View Related

Looping Through A Recordset

I have a recordset which writes out a table. As it is constructed now it loops through and repeats every record, but i want the last two rows to only appear once, but when I try to move the rsProd.MoveNext to where I want the loop to stop I get an error msg saying:

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. Code:

View Replies View Related

Looping Through Folder

I have a folder with about 40 swf training movies.
I want to loop through the folder and display the titles of the movies and make them links.I just need help getting pointed in the right direction to make this happen.

View Replies View Related

Looping Issues

I've got an Array that has split a text field in an Access DB. This Array is now: Array(0) = 1 and Array(1) = 3.

I have another field in another table that has a number and then the name associated with that number.I am wanting to display the name associated with 1 and 3 from my DB but a Do Loop isn't working. I presume because after it displays Array(0) (which it does well) the Looping condition is no longer true because there is no "2" in my array, it skips to 3. So Array(0) works because its true, but then it stops because there is no two but does not pick back up with Array(1).

View Replies View Related

Looping Through Database

I am working on creating reports from an access database. I am trying to populate a table created from the one-to-many relationships in the database. In one column a name appears more than once because it is related to multiple records.

When I display this information I would like to only show the name once in one column but show all of the records it is related to in another.

I have attached a spreadsheet the better explains what I am trying to do. The report is written asp and I have been using loops to write the data to the report. I have also attached the code I am using. The report uses values that the user selects from a map. Then it selects the same values in the database.

View Replies View Related

Looping Insert

I'm currently having some major problems with an insert form that I created
Basically, if a large amount of information is being inserted into the database I get an error
This seems to be a restriction imposed by the host
What I would ideally like to be able to do is to grab so many characters from the textarea insert this into the database and loop this until everything has been inserted (the information would all need to be inserted into the same field of a record)
I've never tried this before so would appreciate any advice/tips on how to go about doing this

View Replies View Related

Looping Problem

I am trying to play multiple songs (as per the user selection) by using <embed> tag.
What is the loop condition I need to use to play the songs one by one. Ex:

<%
ListSong = (Song1.mp3,Song2.mp3) //(Array values differs)
For i = 0 to Ubound(ListSong)
<EMBED SRC="Songs/<%=ListSong(i)%>.mp3" VOLUME="50" AUTOSTART="true" HEIGHT="80" WIDTH="415">
Next
%>

But here the problem is: it's playing the last song in the array. But I need to play first Song1.mp3 and then Song2.mp3

View Replies View Related

Looping Through Recordset

I would like to split a recordset into two parts.
For example, in a left hand column I would to display upto the first 10 records and in the right hand column the next 10 records etc.
I would like this to work even if there are only 3/4 records in total (ie. Less than 10) - so the page would display the first 3/4 records in the left hand column and nothing in the right.
I would like to do this without the use of paging if poss as it needs to be pretty simple!

View Replies View Related

ASP Looping Adding

i have a variable in a database that is looping that outputs numbers like:

1. 45
2. 34
3. 94
4. 34

But are all in the same variable:

DoDateTime((rsBoxEdit.Fields.Item("").Value), 3, 2057)

How can i make it so that it loops that variable and adds the numbers up and outputs 1 variable called total or something?

View Replies View Related

Problem With Looping

Im using the code below to create a calendar. The problem is when it comes to checking how many bookings have been taking on that day and colors it accordingly it doesnt go past the first day.

So say I have a booking on 1/1/2004 it will color it accordingly but wont color any of the rest of the days that have them on as well. Code:

View Replies View Related

Looping Checkboxes

I want somethingh like hotmail, where I don't know the exact amount of records displayed, but when the users checks the boxes and presses submit I can detect which boxes were checked and be able to perform the operation.

View Replies View Related

Looping Through Columns

Normally I do a query, and loop through the records. Is there a way to loop through the columns of each record?

View Replies View Related

Looping Variable

I have a variable that goes through a loop, and each time it appends the new value to the end using a comma. Example:

1st time through:
a = 1
2nd time through:
a = 1, 4
3rd time through:
a = 1, 4, 2

So now after my loop is all done I have this value where each value is seperated by a comma. What I want to do is compare each of the values and display only the largest number. Any ideas on how to do this?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved