KnowlegeZone.com, Share knowledge Gain knowledge
     

Home > ASP : 2D Array in Classic ASP

Question By: n/a   Date: 9/30/2008

2D Array in Classic ASP

How to create a 2D Array in Classic ASP?

Thanks


Share |

Comments.
Comment/Solution Posted By: Saqib    Date: 9/30/2008 3:27:00 PM
its easier then you think.

Think of Ms Excel when creating a 2D array.

Dim MyArray(1,2)

That means my Array will contain ...
1 = Columns
2 = Rows

But remember Array index starts with "Zero/0". so it contains 2 Columns & 3 Rows.

And this is how you can populate them...
MyArray(0,0) = "I am Column 0 & Row 0"
MyArray(1,0) = "I am Column 1 & Row 0"

So we created a Row above with 2 Columns. by changing the index you can move on to next row and columns.

2D Array could be used in Asp classic as well as Asp.net, I use them all the time. you can store data into them and then Loop through them over & over within your page lifecycle.

This is how you Loop.

For i = 0 to ubound(MyArray, 2)
Response.write MyArray(1, 0)
Next

Above will Loop through a 2D array and will print a 2nd column of First Row into the Page.

Happy Programming.
Saqib A. khan

Comment/Solution Posted By: Saqib    Date: 11/1/2008 8:14:00 PM
I've source code of a shopping cart in classic ASP using nothing but 2D Array (No Database involved). Let me know if you need source code.

Thanks

Comment/Solution Posted By: Sesetty Ravi Kumar    Date: 3/24/2009 11:25:00 PM
Hi Saqib,

can you share the source code for my personal development

Thank You,
Regards,
Ravi Kumar

Email: sesettyravikumar@gmail.com

Comment/Solution Posted By: Saqib    Date: 3/25/2009 11:48:00 AM
You mean you want to see Shopping Cart Code?

Thanks

Comment/Solution Posted By: Deon    Date: 8/25/2009 6:37:00 AM
ok so looping through the numeric array is great, however, does anybody know how to loop through an associative array?

Comment/Solution Posted By: Saqib Khan    Date: 8/25/2009 1:25:00 PM
Asp does not really have pure support for associative array. However there is trick that you can use...

CONST AGE = 0
CONST SEX = 1


Redim myArray(1)

myArray(AGE) = "27"
myArray(SEX) = "M"

So you can Constants combined with array to make your own associative array.

Good Luck.

- Saqib
Websolutions Usa Group

Comment/Solution Posted By: Aaryan    Date: 9/15/2009 12:10:00 PM
Hi Saqib,

can you share the source code for ASP shopping cart development

Thank You,
Regards,
aaryan

share at: pandit.aaryan@gmail.com

Comment/Solution Posted By: Saqib    Date: 9/16/2009 5:11:00 PM
Should I post here with instructions... or you prefer Email?

- Saqib


Pages :
Post Comment or Solution   OR   Sign in using Google/Aol/Yahoo/Msn/OpenID
Your Name:  
Your Email:  
Comments:
 
Please Verify:
(Type Answer)