Variables

  • Thread starter Thread starter Dave Ruhl
  • Start date Start date
D

Dave Ruhl

I'm fairly new at Access/VB, but I have 17 years of
experience programming in FoxPro/Visual FoxPro. Most of
the time I can find a comparable way of doing things in
VB, but I've come up with one that has me stumped.

In FoxPro I could use the '&' in front of a variable to
indicate I'm refering to the value of the variable
instead of the variable itself. Example:

foo = "Me.lblHelp.ForeColor"
&foo = 0

Result is Me.lblHelp.ForeColor = 0

Is there a way to code this in VB ???
 
-----Original Message-----
I'm fairly new at Access/VB, but I have 17 years of
experience programming in FoxPro/Visual FoxPro. Most of
the time I can find a comparable way of doing things in
VB, but I've come up with one that has me stumped.

In FoxPro I could use the '&' in front of a variable to
indicate I'm refering to the value of the variable
instead of the variable itself. Example:

foo = "Me.lblHelp.ForeColor"
&foo = 0

Result is Me.lblHelp.ForeColor = 0

Is there a way to code this in VB ???

.
I would just use me.lblHelp.forecolor = 0 or if you
really have a need for the color to be a variable, use foo
instead of 0 after you assign a value to foo.
 
Dave Ruhl said:
I'm fairly new at Access/VB, but I have 17 years of
experience programming in FoxPro/Visual FoxPro. Most of
the time I can find a comparable way of doing things in
VB, but I've come up with one that has me stumped.

In FoxPro I could use the '&' in front of a variable to
indicate I'm refering to the value of the variable
instead of the variable itself. Example:

foo = "Me.lblHelp.ForeColor"
&foo = 0

Result is Me.lblHelp.ForeColor = 0

Is there a way to code this in VB ???

No, I'm afraid you can't use dynamically evaluated assignment
statements. The closest you could come would be string indexes into the
appropriate collections:

Dim CtlName As String
Dim PropName As String

CtlName = "lblHelp"
PropName = "ForeColor"
Me.Controls(CtlName).Properties(PropName) = 0
 
I would just use me.lblHelp.forecolor = 0 or if you
really have a need for the color to be a variable, use
foo instead of 0 after you assign a value to foo.

I just used this as a simple example, what I'm trying to
do is more complicated but uses the same principle.
 
No, I'm afraid you can't use dynamically evaluated
assignment statements. The closest you could come would
be string indexes into the appropriate collections:
Dim CtlName As String
Dim PropName As String

CtlName = "lblHelp"
PropName = "ForeColor"
Me.Controls(CtlName).Properties(PropName) = 0

Thanks Dirk, your solution may work for what I'm trying
to do. Not as easy as FoxPro but then VB hasn't been
around as long.
 
Back
Top