Solved

Arrays in VBScript

Posted on 2004-03-29
15
522 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

778 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