Variable values in variable names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DanubeRS
    New Member
    • Oct 2008
    • 2

    Variable values in variable names

    Hi, i am currently facing a problem where i need to write a loop that sorts through a 2d array in VB6 and assign a certain image to pictures that are named incrementally based on the value of that array position. Rather than having to write a seperate piece of code for every single variable (there are over 60 different variables) is there a way i can incrementally store values?

    To clear things up:

    how can i...
    Code:
    picture1.picture = array(1,1)
    
    picture2.picture = array(1,2)
    
    picture3.picture = array(2,1)
    etc...

    if i was to code it all manually i would have to write over 60 lines of pretty much the same thing. is there a way to do something like this:

    Code:
    i = 1
    
    Do While i <> 61
    
       Dim varName as String
    
       varName = "picture" & i
    
       'varname translates to picture #x incrementally from 1
       varName.picture = array(1,1)
    
    
       i = i + 1
       
    Loop
    thanks

    `DanubeRS
  • DanubeRS
    New Member
    • Oct 2008
    • 2

    #2
    bump!!!

    anyone able to help?

    `DanubeRS

    Comment

    Working...