Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

Arrays in VBScript

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
Tom Knowlton
Asked:
Tom Knowlton
  • 7
  • 4
  • 2
  • +2
4 Solutions
 
samdlgCommented:
Dim newArray()
0
 
Tom KnowltonWeb developerAuthor Commented:
And then how would I add elements to the array?
0
 
samdlgCommented:
here's the rest:

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


0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
samdlgCommented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
The array would have to be global to the various ASP pages that use it.
0
 
Saqib KhanSenior DeveloperCommented:
Dim newArray(2)
newArray(0) = 0
newArray(1) = 1
newArray(2) = 2

OR

Dim newArray("one", "Two", "Three")
response.write newArray(0)
0
 
Tom KnowltonWeb developerAuthor Commented:
I will probably just DIM the array to handle say 20 elements.

This should be more than I need.
0
 
samdlgCommented:
so...did I answer your question?  if so, please reward me the points, I need to ask a few others.

thanks.
0
 
Tom KnowltonWeb developerAuthor Commented:
samdig:  I am evaluating all the answers I have gotten.
0
 
jitgangulyCommented:
>>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
 
alorentzCommented:
Refer to my answer in your other question...
0
 
Tom KnowltonWeb developerAuthor Commented:
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
 
alorentzCommented:
Sorry, that's why I'm in the ASP area...I don't support Javascript unless I have too.
0
 
Tom KnowltonWeb developerAuthor Commented:
Fair enough.  :)
0

Featured Post

Technology Partners: 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!

  • 7
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now