Click to See Complete Forum and Search --> : vb variable macros


Russ Billard
July 16th, 2001, 10:56 PM
In clipper you could macro your variables. so a variable could be called peanut&a where "a" could be either butter or oil. peanutbutter and peanutoil would have seperate values anyone know a vb way of doing the same?

Cakkie
July 17th, 2001, 12:53 AM
Something like this?

a = "oil"
'....
b = "peanut" & a




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Russ Billard
July 17th, 2001, 01:20 AM
more so like
a=1
period&a = 1
a=a+1
Period&a = 2

results

period1=1
period2=2

Cakkie
July 17th, 2001, 01:43 AM
Oh, that isn't really possible in VB, what is possible is to create an array, and address it via it's index, like this:

Dim peanut(1 to 3)
a = 1
peanut(a) = 1
a = 2
peanut(a) = 2
a = 2
peanut(a) = 3
' results in
peanut(1) = 1
peanut(2) = 2
peanut(3) = 3





Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Russ Billard
July 17th, 2001, 10:17 AM
Thanks, I'm very familier with arrays.

Clearcode
July 17th, 2001, 10:43 AM
Or you could use a Collection class and key it thus:



Dim Peanut as Collection

set Peanut = new Collection

Peanut.Add "£3.10","Oil"
Peanut.Add "£2.50","Butter"

Debug.print Peanut("Oil")




HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.