asp_web_howto thread: dynamic naming of variables
Message #1 by "NAME REMOVED" <EMAIL REMOVED> on Mon, 17 Dec 2001 12:36:42
|
|
Hi...
Is it possible to pass a function a variable name (previously declared)
and use that name for a certain variable in the function. I have a
function that does exactly the same thing in six sets of circumstance. In
each different circumstance the function should set the value of a
different variable. I want to pass the function the correct variable name
and make it use that variable name in the code of the function.
Thanks
GDP
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 18 Dec 2001 10:35:12 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "NAME REMOVED" <EMAIL REMOVED>
Subject: [asp_web_howto] dynamic naming of variables
: Is it possible to pass a function a variable name (previously declared)
: and use that name for a certain variable in the function. I have a
: function that does exactly the same thing in six sets of circumstance. In
: each different circumstance the function should set the value of a
: different variable. I want to pass the function the correct variable name
: and make it use that variable name in the code of the function.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<%
Function DoStuff( _
ByVal strInput _
)
DoStuff = strInput & " done"
End Function
'
'
strFirstVar = DoStuff(strFirstVar)
strSecondVar = DoStuff(strSecondVar)
strThirdVar = DoStuff(strThirdVar)
Here you pass three different variables to the function. The function does
it's stuff and returns the result which you store in the variable.
Sorry if this is missing the point of what you're trying to do. If so, can
you elaborate more on what you want to do?
Cheers
Ken
Message #3 by "NAME REMOVED" <EMAIL REMOVED> on Wed, 19 Dec 2001 09:26:48
|
|
Hi...thanks for the reply...your answer is sort of helpful, except i need
to not just set more than one variable from the function. i am going to
use a big select case which will work off a passed flag, the value of
which will determine which variable name to use.
thanks
Message #4 by "Ken Schaefer" <ken@a...> on Wed, 19 Dec 2001 20:38:14 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "NAME REMOVED" <EMAIL REMOVED>
Subject: [asp_web_howto] Re: dynamic naming of variables
: Hi...thanks for the reply...your answer is sort of helpful, except i need
: to not just set more than one variable from the function. i am going to
: use a big select case which will work off a passed flag, the value of
: which will determine which variable name to use.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Can you please explain in more depth what you need? From what you say I
don't see why you can't set the value of the variable you need to change to
be the *return* value of the function?
<%
Dim foo
Dim bar
' Updates a variable called foo
foo = DoStuff(foo)
' Updates a variable called bar
bar = DoStuff(bar)
Function DoStuff( _
ByVal strInput _
)
strInput = strInput & " Done"
End Function
%>
Cheers
Ken
|