Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


..

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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


.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I change a Name scope from local to Global? Henry Excel Discussion (Misc queries) 7 April 9th 10 10:36 PM
How can I change a Name scope from local to Global? Henry Excel Discussion (Misc queries) 0 September 23rd 08 07:24 PM
Global name used in local version clara Excel Discussion (Misc queries) 3 June 16th 08 06:54 PM
User Defined Functions - local or global? Simon Excel Worksheet Functions 5 September 27th 06 09:15 AM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"