469,159 Members | 1,454 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,159 developers. It's quick & easy.

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...
Expand|Select|Wrap|Line Numbers
  1. picture1.picture = array(1,1)
  2.  
  3. picture2.picture = array(1,2)
  4.  
  5. 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:

Expand|Select|Wrap|Line Numbers
  1.  
  2. i = 1
  3.  
  4. Do While i <> 61
  5.  
  6.    Dim varName as String
  7.  
  8.    varName = "picture" & i
  9.  
  10.    'varname translates to picture #x incrementally from 1
  11.    varName.picture = array(1,1)
  12.  
  13.  
  14.    i = i + 1
  15.  
  16. Loop
  17.  
  18.  
  19.  
thanks

`DanubeRS
Oct 4 '08 #1
1 1099
bump!!!

anyone able to help?

`DanubeRS
Oct 6 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Michael Krasnyk | last post: by
23 posts views Thread by stewart.midwinter | last post: by
8 posts views Thread by Thomas Mlynarczyk | last post: by
166 posts views Thread by Graham | last post: by
6 posts views Thread by Marcus Kwok | last post: by
10 posts views Thread by John Salerno | last post: by
7 posts views Thread by loial | last post: by
5 posts views Thread by panthera | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.