Dynamic variable



Hi,

I was wondering if there was a way of doing something like...

/////////////////////////////////////////////

Dim g_ValA ' global values set somewhere
Dim g_ValB
Dim g_ValC
Dim g_ValD

Function GetValue( sItem )
GetValue = {sItem}.Value
End Function

....
Function SomeOtherFunction()

GetValue( "g_ValA" ) ' return the value of g_ValA
GetValue( "g_ValB" ) ' return the value of g_ValB
GetValue( "g_ValZ" ) ' return an error of some sort as g_ValZ
does not exist.

End Function
/////////////////////////////////////////////

where {sItem}is the name of a variable.
I think it can be acheived in PHP by doing something lke ${val}

Can it be done in VBScript?

Many thanks in advance.

Simon


.



Relevant Pages

  • HOWTO: Reset system menu?
    ... Simon ... Private Property Let DisableClose ... Dim l_hMenu As Long ... Prev by Date: ...
    (microsoft.public.vb.winapi)
  • Re: Dynamic variable
    ... >> Dim g_ValA ' global values set somewhere ... >> Function GetValue(sItem) ... i am using VBScript in my C++ program to allow users to run ... Simon ...
    (microsoft.public.scripting.vbscript)
  • Re: Dynamic variable
    ... > Dim g_ValA ' global values set somewhere ... > Function GetValue(sItem) ... Prev by Date: ...
    (microsoft.public.scripting.vbscript)
  • Re: How to return a value from a function?
    ... Function GetValue() as Long ... Dim i as Long ... the answer is Exit Function. ... How can I do the same thing in Excel VBA? ...
    (microsoft.public.excel.programming)
  • RE: Re : Excel Range of Values Amidst Characteristic Transitions
    ... Dim Curr As Range, Prev ... If RowArray1 Is Nothing Then ...
    (microsoft.public.excel)