Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dynamic ASP Local Variables...

Reply
Thread Tools

Dynamic ASP Local Variables...

 
 
@sh
Guest
Posts: n/a
 
      01-05-2006
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!


 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      01-05-2006
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" <(E-Mail Removed)> wrote in message
news:dpj8u7$ggb$(E-Mail Removed)-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!
>



 
Reply With Quote
 
 
 
 
@sh
Guest
Posts: n/a
 
      01-05-2006
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:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:dpj8u7$ggb$(E-Mail Removed)-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!
>>

>
>



 
Reply With Quote
 
paul@bullschmidt.com
Guest
Posts: n/a
 
      01-10-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET 2.0: Sending email on local domain to local exchange 2K server Jim in Arizona ASP .Net 8 01-24-2006 05:37 PM
Access local port or Running local exe file =?Utf-8?B?WVNVVA==?= ASP .Net 0 01-14-2006 12:41 AM
Can a local resource string be dynamic (asp.net 2.0) Peter Strĝiman ASP .Net 1 08-23-2005 11:20 AM
Browser link to local file works when local, not work when servedfrom http lurker HTML 1 04-05-2005 05:10 AM
Can't use 'local' to find sql server instances on local machine karim ASP .Net 1 06-26-2003 09:17 PM



Advertisments