Dim in For Loop Errs outside For Loop

Results 1 to 3 of 3

Thread: Dim in For Loop Errs outside For Loop

  1. #1
    Joris van Lier Guest

    Default Dim in For Loop Errs outside For Loop

    Hi, I just started to get high on ASP and need to do a file-upload and save the filename to a database..<BR>I&#039m using the AspSmartUpload Component for this job.<BR><BR>I&#039m using a "for each" loop to Dim the name and set the value of the form-elements like this<BR><BR>For each item In mySmartUpload.Form<BR>For each value In mySmartUpload.Form(item)<BR>Response.Write(item & " = " & value & "<BR>")<BR>Dim item<BR>item = value <BR>Next<BR>Next<BR><BR>then i want to re-use this value to insert it into my DB<BR><BR>Now here&#039s my problem :<BR>Outside the "For each" loop it errs with "Variable not defined".<BR><BR>What am I doing wrong? <BR>Should I Make those vars Public?<BR>If so.... how should I do that?<BR><BR>Thanx <BR><BR>Joris van Lier (whizzrd@iname.com)<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Dim in For Loop Errs outside For Loop

    why nested loops? are you uploading multiple files?<BR><BR>also, which actual line throws the error? you shouldn&#039t be dim-ming within the loop. dim outside, then the variable is re-usable....<BR><BR>the rest of the code and an outline of what gets posted to the page would be good...<BR><BR>jason

  3. #3
    Diesy Okankwu Guest

    Default RE: Dim in For Loop Errs outside For Loop

    Hi,<BR><BR>Why do you use the item var before you declare it?<BR><BR>For Starters, I think you should move the declaration statement out of the for loop to either form level or app level.<BR>This will ensure that item is available before you use it to update your DB.<BR><BR>Good Luck.<BR>ibaaman@hotmail.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts