Solved

Arrays in VBScript

Posted on 2004-03-29
15
520 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:knowlton
  • 7
  • 4
  • 2
  • +2
15 Comments
 

Expert Comment

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

Author Comment

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

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: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:knowlton
ID: 10706977
The array would have to be global to the various ASP pages that use it.
0
 
LVL 23

Assisted Solution

by:adilkhan
adilkhan 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Author Comment

by: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: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: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:knowlton
ID: 10707827
Fair enough.  :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now