Re: Dim Array Problem in VBScript

by "Cyanide _7" <leo7278(at)hotmail.com>

 Date:  Mon, 28 Feb 2000 01:42:09 CST
 To:  tom(at)piedpiper.com.au
 Cc:  hwg-languages(at)hwg.org
  todo: View Thread, Original
you need to use REDIM for this. its the only way i know to initialize and 
array with a variable length:

<%
Dim i
Redim q(Cint(Request.Form("c")))
For i = 1 to t
q(i) = Request.Form(i)
Next
%>

- Cyanide_7


>
> > I need to DIM an array with a value (t) determined by a string
> > passed via a form (Request.Form("c")).
> > Why won't the following script work?  The statement "Dim q(t)"
> > generates the error, "Expected integer constant" although
> > I've made the "Request.Form" string result into an integer
> > varient type with "Cint".  Do I HAVE to use a literal integer
> > where I want to use the varible "t"?
> > (When I use 1,2,3, etc., it works, but I have to know the
> > value of "t" ahead of time,
> > which defeats the purpose of what I'm trying to do.)
> > <%
> > Dim i
> > Dim t
> > t = Cint(Request.Form("c"))
> > Dim q(t)
> > For i = 1 to t
> > q(i) = Request.Form(i)
> > Next
> > %>
>
>
>Hi Conrad...
>I dont know the answer to your question as I know nothing about VB script
>but have done a little programming in VB (Access) and you declaration
>statement looks odd to me ......surely you need to declare the variables of
>your array separately
>and THEN declare your array.
>
>  <%
>  Dim i
>  Dim t
>  Dim q
>
>  t = Cint(Request.Form("c"))
>
>  For i = 1 to t
>  q(i) = Request.Form(i)
>  Next
>  %>
>As already stated I know nothing of VBscript so I have answered mainly to
>provoke comment from others...
>
>the other thing ...Dont you have to declare your variables AS something
>  dim i as integer etc)
>
>hope It has helped (probably not)
>
>Tom Keatley
>
>
>

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA