Solved

Arrays in VBScript

Posted on 2004-03-29
15
521 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passing special characters in http get request 7 39
iis reverse proxy virtual directory 8 134
ASP Classic - Load test 2 45
Adding Datediff to staistics page 2 49
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

18 Experts available now in Live!

Get 1:1 Help Now