variable name building in loop

Results 1 to 3 of 3

Thread: variable name building in loop

  1. #1
    Anton de Wit Guest

    Default variable name building in loop

    Ewo all :)<BR><BR>Here&#039s my prob.<BR>I want a loop to insert values in an SQL statement and execute this. The var-names however are dependant on the loop number. Building strings is easy this way, but how can I do this with variable names? Coz as far as I know I can&#039t use a string as a variable name...<BR><BR>Thanx in advance<BR><BR>Example:<BR><BR>VAR1 = 1<BR>VAR2 = 45<BR>VAR3 = 6<BR><BR>FOR i = 1 to 3 <BR> strSQL = "INSERT INTO Table VALUES(" + VARi + ")"<BR> Comm.execute etc yaddiyaddiya<BR>NEXT<BR><BR>(Where the VARi is the part I cannot do at the moment and which should read ofcoz in the according loops VAR1, VAR2, VAR3)<BR>

  2. #2
    Join Date
    Dec 1969

    Default Array

    It would be much easier for you to put these values into an array, then access the array in the query.<BR><BR><BR>FOR i = 1 to 3 <BR>var(i) = var & i<BR>strSQL = "INSERT INTO Table VALUES(&#039" & var(i) & "&#039)"<BR><BR>Comm.execute etc yaddiyaddiya<BR>NEXT<BR><BR>

  3. #3
    Anton de Wit Guest

    Default RE: Array

    Thanx!!!<BR><BR>I see what u mean.<BR>/me starts recoding :)

Posting Permissions

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