473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dynamic ASP Local Variables...

@sh
I'd like to create a series of variables created dynamically, example such
as this...

For i = 1 to 5
TheVariable & i = "blah"
Next

This would during the first loop create a variable called 'TheVariable1'
with a value of 'blah'. Is this possible as so far I'm getting syntax
errors?

Cheers!
Jan 5 '06 #1
3 1415
Use an array!
Dim TheVariable[4]
For i = 1 to 5
TheVariable[i] = "blah value #" & i
Next

Response.Write "For example, the third value is " & TheVariable[2]

(Arrays are zero-based in vbscript, so the first element is 0, second is 1,
and so on.)

Ray at work

"@sh" <sp**@spam.com> wrote in message
news:dp**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
I'd like to create a series of variables created dynamically, example such
as this...

For i = 1 to 5
TheVariable & i = "blah"
Next

This would during the first loop create a variable called 'TheVariable1'
with a value of 'blah'. Is this possible as so far I'm getting syntax
errors?

Cheers!

Jan 5 '06 #2
@sh
That is so ridiculously obvious I'm blushing....sorry - I'm getting "haven't
developed for a while" syndrome, where functions/commands begin to creep
back into your mind, hehe

Many thanks!
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:eF**************@TK2MSFTNGP10.phx.gbl...
Use an array!
Dim TheVariable[4]
For i = 1 to 5
TheVariable[i] = "blah value #" & i
Next

Response.Write "For example, the third value is " & TheVariable[2]

(Arrays are zero-based in vbscript, so the first element is 0, second is
1, and so on.)

Ray at work

"@sh" <sp**@spam.com> wrote in message
news:dp**********@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
I'd like to create a series of variables created dynamically, example
such as this...

For i = 1 to 5
TheVariable & i = "blah"
Next

This would during the first loop create a variable called 'TheVariable1'
with a value of 'blah'. Is this possible as so far I'm getting syntax
errors?

Cheers!


Jan 5 '06 #3
And/or you may also want to check this out:

Using the Eval and Execute Functions - 3/3/2000
http://www.4guysfromrolla.com/webtech/030300-1.shtml

Best regards,
J. Paul Schmidt, Freelance Web and Database Developer
http://www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips

Jan 10 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: alexandre damiron | last post by:
Did anyone tried dynamic variable naming in Js, like the ${$varname} feature of PHP ? It would easier a long DOM generation, for example to place such a code portion into a loop .... ...
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
26
by: Jerim79 | last post by:
I need to create a form that takes a number that the user enters, and duplicates a question the number of times the user entered. For instance, if the customer enters 5 on the first page, when...
12
by: Nehil | last post by:
can i find about following 2 things, by providing my own API of functions for a C program : 1) static, global and const section of variables (pointers only), and to pickout only those which are...
1
by: Suleman | last post by:
Write a Program in some language that has both static and stack-dynamic local variables in subprogrms. Create six large (at least 100*100 ) matrices in the subprogram,three static and three stack...
14
by: vivek | last post by:
i have some doubts on dynamic memory allocation and stacks and heaps where is the dynamic memory allocation used? in function calls there are some counters like "i" in the below function. Is...
26
by: Aaron \Castironpi\ Brady | last post by:
Hello all, To me, this is a somewhat unintuitive behavior. I want to discuss the parts of it I don't understand. .... f= lambda: n .... 9 9
4
by: RakuRay | last post by:
I am having trouble with dynamic SQL. Early in my code I assign data to a bunch of local variables. I want to access these later in my code and use the data values. The code example below shows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.