[thelist] VBScript - declaring dynamically named vars in a Fo rloop
Pringle, Ron
RPringle at aurora-il.org
Thu Mar 3 15:56:26 CST 2005
> > I'm trying to declare variables named in numeric sequence
> > based on the name of each dynamic field. So something like this:
>
> Ok. I'm not 100% sure I understand what you are trying to
> do, but here's
> some feedback nonetheless.
>
> > Dim dateCount
> > Dim howMany
> > howMany=request.form("howMany")
> > dateCount=1
> >
> > For x = dateCount To howMany
> > Dim sEventDate(x)
>
> This is problem number one. sEventDate is an array. Use Dim
> to declare it
> once and then ReDim Preserve to resize it withot destroying
> its contents.
Ok, backing up here. How to I declare an array with a value that is passed
as a variable from a form?
Assuming I have a text input form where a number is entered, and that form
field is named "howMany". Lets say I've input "2" in that field, so using
the below code:
howMany = CInt(request.form("howMany"))
howMany should have an integer of 2 as its value, correct?
Now I want to dimension an array with the size of "howMany". I've tried
writing it out as:
Dim sEventDate(howMany)
That just throws an error saying "Expected integer constant".
I'm sure this is some fundamental of VBScript that I am just completely not
understanding here.
Ron
More information about the thelist
mailing list