473,703 Members | 2,644 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable values in variable names

2 New Member
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 1212
DanubeRS
2 New Member
bump!!!

anyone able to help?

`DanubeRS
Oct 6 '08 #2

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

Similar topics

1
2081
by: Michael Krasnyk | last post by:
Hi, How can I print variable values by their names? For example: import sys for str in dir(sys): print str Will be printed only variable names, but I need values from list of variable names.
23
63682
by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two vars, along with their names. I could easily do this: print "myPlace = %s, myTime = %s" % (myPlace, myTime)
8
1432
by: Thomas Mlynarczyk | last post by:
Hi, I want to pass a variable to a function and that function should display both the value and the name of that variable. As for the value - no problem, but the name? So far I've come up with function foo() { var myVar = 5; var myOtherVar = 'bla'; showVars( {myVar: myVar, myOtherVar: myOtherVar} );
166
8621
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
6
6152
by: Marcus Kwok | last post by:
I am designing a GUI (my question is not about GUIs) and I have named my variables using a regular naming scheme. However, in order to simplify the code using these variables, I have created an array of non-owning pointers to these variables. I am trying to write a macro to generate these variable names for me, but I am not sure if what I want to do is possible. The code below demonstrates what I want to do (except it is generating...
5
1835
by: glenn | last post by:
Hi folks, The problem I have is that a query string works if hard-coded but if I pass a variable to it, it does not work as shown here. This works: querystring="SELECT * FROM USERS WHERE CNAME = 'MICROSOFT'" This does not work: Dim var as string
5
1380
by: Takeadoe | last post by:
Dear NG - I was able to figure out how to use the IIF to compute the difference in deer-vehicle accidents between years (2004 and 2005). My question is, is it possible to use the results of the parameters in the variable names or as variable names themselves? For instance, instead of and , is it possible to somehow use the returned value of YEAR1 and YEAR2 (in this case, 2004 and 2005) either as new variable names or parts thereof...
10
7113
by: John Salerno | last post by:
If I want to have a list like this: where the first part of each tuple is a variable name and the second part is a label for the user to see, such as a form like this: First Name: ________ Last Name: ________
7
2526
by: loial | last post by:
I need to store a list of variable names in a dictionary or list. I then later need to retrieve the names of the variables and get the values from the named variables. The named variables will already have been created and given a value. I hope thats clear!!! How can I do this?
5
2634
by: panthera | last post by:
Hi, I have a problem regarding generating variable names in my program.Suppose I have 10 variables b0,b1,b2...b9.They are NOT in an array.And I want to randomly select one of them and get its value.So I pick a random number between 0 and 9 and concat it with 'b' to get the name of this variable.But how do I get the value of this variable? I tried to define a macro using b##num,but it results in bnum instead of b5 for example.
0
8741
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8658
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9239
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7842
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6583
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4674
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2419
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2049
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.