Referring to an object using a string

P

PC

Not sure of the technical term for this but an example of
what's stumping me is this:

Say I have three constants:
const CONV_DWEEZIL = 1
const CONV_MOONBUCKET = 2
const CONV_FRANK = 3

and I have write a function that will have an argument
passed with just the name and a value:

I want to be able to reference the correct constant (or
variable etc) by concatanating the strings. I know I've
done it with other packages but can't find the correct
syntax in VBA.

e.g.

function TimesName(ac_Value as currency, as_Name as
string) as currency
TimesName = ac_Value * _
"CONV_" & as_Name

end function
 
J

jaf

Hi,
Sorry, but you can't ref a constant as a variable or vice versa.

It will work if you use variables.
CONV_DWEEZIL = 1
CONV_MOONBUCKET = 2
CONV_FRANK = 3
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top