Solved

Arrays in VBScript

Posted on 2004-03-29
15
530 Views
Last Modified: 2006-11-17
How do I declare and use an array in VBScript?

My goal is to use an array to accumulate a bunch of SQL statements.....then loop through them and run Conn.Execute(array[x]) for each one.
0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
  • +2
15 Comments
 

Expert Comment

by:samdlg
ID: 10706933
Dim newArray()
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10706950
And then how would I add elements to the array?
0
 

Expert Comment

by:samdlg
ID: 10706953
here's the rest:

for i = 0 to UBound(newArray)
  newArray(i) = "newValue" & i
next


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
samdlg earned 200 total points
ID: 10706966
Do you know how many elements will be contained in the array?
if you do then.

Dim newArray(10)

if you don't then

Dim newArray()
Redim newArray(10)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10706970
I want to add elements to the array inside different Subroutine and Function calls.....then when the user clicks "submit"....loop through the array.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10706977
The array would have to be global to the various ASP pages that use it.
0
 
LVL 23

Assisted Solution

by:Saqib Khan
Saqib Khan earned 150 total points
ID: 10706985
Dim newArray(2)
newArray(0) = 0
newArray(1) = 1
newArray(2) = 2

OR

Dim newArray("one", "Two", "Three")
response.write newArray(0)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10707010
I will probably just DIM the array to handle say 20 elements.

This should be more than I need.
0
 

Expert Comment

by:samdlg
ID: 10707020
so...did I answer your question?  if so, please reward me the points, I need to ask a few others.

thanks.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10707029
samdig:  I am evaluating all the answers I have gotten.
0
 
LVL 20

Assisted Solution

by:jitganguly
jitganguly earned 100 total points
ID: 10707266
>>then loop through them and run Conn.Execute(array[x]) for each one.

Then you need this

dim sql(3)
sqL(0)="select * from a"
sql(1)="select * from b"
sql(2)="select * from c"

for i = 0 to ubound(sql)
      response.write sql(i) & "<br>"
      conn.execute(sql(i))
next
0
 
LVL 31

Assisted Solution

by:alorentz
alorentz earned 50 total points
ID: 10707427
Refer to my answer in your other question...
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10707762
alorentz (and the other Experts).


I want to change the way I am doing things.....and have JavaScript control the game board at runtime, and record the information behind each game piece:


http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20936405.html
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10707823
Sorry, that's why I'm in the ASP area...I don't support Javascript unless I have too.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 10707827
Fair enough.  :)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question