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


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

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 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

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

Vbscript Array

I want to create an array using:

numArray(x)

where x is a dynamic number, but it doesnt work?

View Replies View Related

Array In Vbscript

normally array start with 0 position.. can we start our array from 5 position in vbscript.

View Replies View Related

VBscript Date Array

I would like to get the full date of every Saturday in the year in an array - starting with the very last Saturday of last year, and ending with the first Saturday of next year. Is there a way to do this using the vbscript date functions?

View Replies View Related

String-indexed Array In ASP VBScript

Can i use string indexed arrays in ASP?
Such as in PHP: $arr['string_index']='ok'?

View Replies View Related

Multidimensional Array :: Microsoft VBScript Runtime (0x800A000D)

Hello all,

I am extremely stuck. I am trying to create a simple shopping cart yet keep running into the same type mismatch error everytime, no matter what I do. I have read countless articles about this, even posts in this forum, I've followed their code exactly and still I get the same error.

In the global.asa i am trying to create a multidimensional array with just two columns, product id and quantity, keeping it simple for now.
global.asa
SUB Session_OnStart
CONST CART_COLUMNS = 1
Dim cartArray()
ReDim cartArray( CART_COLUMNS, 1 )
cartMaxUsed = -1
Session("cartArray") = cartArray
Session("cartMaxUsed") = cartMaxUsed

END SUB

Now in my subsequent asp pages I have created functions to add to the array, following code exactly from articles, posts, etc., but everytime I would run them, it would fail on a type mismatch error when I tried to get the UBound of the array.

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/store/add.asp, line 10

So just for testing I simplified it as much as possible and it would still fail on the same line of code. Here is the code for add.asp

Dim cartArray
Dim cartMaxUsed
cartArray = Session("cartArray")
cartMaxUsed = Session("cartMaxUsed")
dim num
num= UBound(cartArray, 2)
response.write num 'for testing purposes
response.end 'only


everytime it fails at the UBound line.

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

Rebuilding Of An Array From An Existing Array

I dump the entire recordset into an array:

If not rs.EOF Then
aEmp = rs.GetRows()

Contents of the array are in this order:

EmpID,EmpName,Indent,Sub_ID,Lft,Rgt,MgrID, LastName

This query sort on the basis of Lft and Rgt columns.

The name of the array is: aEmp.

My question here is how can I get only the LastName from the aEmp array into another array so that I can sort the names alphabetically and then display the employees in the alphabetical order.

Or is there is another way I could this by using the same array while keeping the lft and rgt sort of the query? If I sort based at the SQL query level, I can see the names sorted by the lft, rgt and lastname, but since the lastname is at the end of the sort list - it does not appear alphabetically.

View Replies View Related

Array Integers Vs Array Variables

In working with arrays, I have found that I am unable to dimension and array
with a variable that has an integer value but I can redimension one this
way. I haven't see any information that tells me if this is a requirement,
although it appears to be because I get an error if I try it.

Ex.

Dim b
b = 10
Dim a(b) ' this errors out but
Dim a() ' this
Redim a(b) ' works

Code:

View Replies View Related

Create A New Array From An Array

I want to create a new array called arrNames2 and copy contents of arrNames to arrNames2.

I then want to loop through my db and add more names (while going through the loop) to arrNames2. What is the best way to do this? Do I have to keep redim the array wehn I add more names?

View Replies View Related

Array In Sql

i want to excute given logic

select * from Product_Table where Product_Code in

ARRAY

i.e i want to select Product_Code from VB array and not from a query
is it possible.

View Replies View Related

Array

I know I can do this programatically using a loop but I thought there might be
some easier or more effective way.

I am trying to invert an array.

i.e.

array1 = 1,2,3,4,5

but I want to get

array2 = 5,4,3,2,1

Is there something like array2 = invert(array1)?

View Replies View Related

Array

I have to following code:Code:

dim arrRes(9),getal,som
arrRes=Array(4,4,4,4,4,5,5,5,5,5)
for getal=0 to 9
som=som+arrRes(getal)
next
response.write("Het klasgemiddelde is " &som/10)

I get a type not match error on the second line

View Replies View Related

ASP Array?

I have a page in my admin system where the user can edit products they
have added. The problem I am having is with Related Products. These are
all listed in a multiple list. What I need to do is have those selected
when the product was added, already be highlighted in the multiple list
on the product edit page. Here is my post from another forum.

Code:

View Replies View Related

Array

For some reason, when I try to run the following array, I'm getting an
error:

dim cat(0)

cat(0)="0407"
cat(1)="0102"

'I will be adding more to this array, but just trying with two for
starts.

for counter = 0 to 1

itno=cat(counter)

'I get an error when it runs through this function

Function rightvar(theVar,lengthNeeded)
Dim sResult
sResult=theVar
if Len(theVar)< lengthNeeded then sResult= String(lengthNeeded -
Len(theVar)," ")& theVar
rightvar=sResult
End Function

Can someone help me understand why?

View Replies View Related

Array

The problem is that in my 5 years of programming in various languages i have never really understood arrays (DUMB @$${lol})
What i want to do is offer an advanced search of a database table on my website. I currently offer the functionality so that the whole of the database can be viewed within the web page so that it doesn't need to be downloaded/need access to view it.
What i need to do is run a script that takes all of the column headings that i have and put them into an array. Then with the array i need to output each element into a drop down box.

View Replies View Related

Asp Array

Ok what I have is a little script which runs through my stock compares how many of one item we have compared to what we need and displays the out come.

What id like to do is make an array with the item name so lets say If how many is needed is greater then 0 then add the name of that consumable to an array and move on until the end.

Then I want to use the arry to display each consumable on an order form. Anyone have any idea how to do this in ASP or can give me any advice on a better way to do it?

View Replies View Related

Array

I am doing the following:
Code:

dim n
n=4'ubound(arrsequences)
response.write "n:" & n
dim arrproductNames(n)
dim arrproductSeq(n)

and getting the following error:
Microsoft VBScript compilation error '800a0402'
Expected integer constant
process.asp, line 33
dim arrproductNames(n)

View Replies View Related

Add Something To An Array

How can I add something to an array, e.g
[VBS]
Dim MyArray

MyArray = Array("Item 1", "Item 2", "Item 3")

'Do some code here

'I now want to add another item to my array, how?
[/VBS]

View Replies View Related

An Array

Is there a way of determining whether or not a value or values are present in an array.
Is there something nice and easy as with php's

if(in_array($SomeValue,$myArray)){
echo "The value is here";
}
else{
echo "The value is not here";

View Replies View Related

ASP Array

how to store request multiple value(Select box) in an array.

View Replies View Related

2D Array

im trying to write a script that will allow me to take names and addresses
from a coma delimetered text file and insert them into a db.

ive managed to come up with this script which deals with works well if i
only have names in the text file. ie:

bob smith, peter smith, brian smith

but now i want to do something simular with a text file formatted like so

bob smith, bob smiths address, peter smith, peter smiths address,

i think i have to use a 2 demensional array but really have no idea how to
go about it. any help appreciated. here is what i have so far. Code:

View Replies View Related

Array

I have a form that has fields named Title1, Title2, and so on to title 12

I want to set up an array that goes through all the input feild values that I already put into variables such as Title1, Title2...so on. It then replaces ' with '' so the apostrophe can be entered into the database. So it:

Creates an array by looping through the variables that get the form feilds.

Then loops through the array and replaces the ' with '':
Title1=(Replace(Title2, "'", "''"))

View Replies View Related







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