472,097 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,097 software developers and data experts.

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)
  3. picture2.picture = array(1,2)
  5. picture3.picture = array(2,1)

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
  2. i = 1
  4. Do While i <> 61
  6.    Dim varName as String
  8.    varName = "picture" & i
  10.    'varname translates to picture #x incrementally from 1
  11.    varName.picture = array(1,1)
  14.    i = i + 1
  16. Loop

Oct 4 '08 #1
1 1154

anyone able to help?

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
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.