![]() |
Referring to a local or global variable or constant dynamically?
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 part of the name of a constant (or global variable) 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 **** I want this line to act as though it read --- end function .. |
Referring to a local or global variable or constant dynamically?
There isn't any support for this like there is in Foxpro or dbase for
example. You would have to use a case statement I would think Select Case as_Name Case "DWEEZIL" lngMult = CONV_DWEEZIL Case "MOONBUCKET" lngMult = CONV_MOONBUCKET Case "FRANK" lngMult = CONV_FRANK End Select TimesName = ac_Value * lngMult -- Regards, Tom Ogilvy "PC" wrote in message ... 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 part of the name of a constant (or global variable) 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 **** I want this line to act as though it read --- end function . |
All times are GMT +1. The time now is 07:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com