Solved

Arrays in VBScript

Posted on 2004-03-29
15
524 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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problems using Provider=OraOLEDB.Oracle via VBScript/Classic ASP 5 105
One field not displaying content (ASP Classic) 8 35
Obtaining data on ASP 8 35
Replace value 2 27
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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

685 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