Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Call subroutine by variable value

Reply
Thread Tools

Call subroutine by variable value

 
 
gabba
Guest
Posts: n/a
 
      09-12-2006
Hi,
is it possible to call a subroutine (or a function) using variable name?

Sub a()
Response.write("sub a")
End sub

Sub b()
Response.write("sub b")
End sub

Sub c()
Response.write("sub c")
End sub

Dim subname
subname = "b"
**call subname**
'does exist something like this? or something like the javascript 'eval' ?

Thanks..



 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      09-12-2006
See the VBScript "Execute" statement as a last resort...

You could also use classes (though VBSciprt has limited support for this)
depending on what is the overall goal.

--
Patrice

"gabba" <(E-Mail Removed)> a écrit dans le message de news:
4506e1de$0$998$(E-Mail Removed)...
> Hi,
> is it possible to call a subroutine (or a function) using variable name?
>
> Sub a()
> Response.write("sub a")
> End sub
>
> Sub b()
> Response.write("sub b")
> End sub
>
> Sub c()
> Response.write("sub c")
> End sub
>
> Dim subname
> subname = "b"
> **call subname**
> 'does exist something like this? or something like the javascript 'eval' ?
>
> Thanks..
>
>
>



 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      09-12-2006
"gabba" <(E-Mail Removed)> wrote in message
news:4506e1de$0$998$(E-Mail Removed)...
> Hi,
> is it possible to call a subroutine (or a function) using variable name?
>
> Sub a()
> Response.write("sub a")
> End sub
>
> Sub b()
> Response.write("sub b")
> End sub
>
> Sub c()
> Response.write("sub c")
> End sub
>
> Dim subname
> subname = "b"
> **call subname**
> 'does exist something like this? or something like the javascript 'eval' ?


"Eval" exists in VBScript and is described as:
"Evaluates an expression and returns the result."

"Execute" will do what you want:
"Executes one or more specified statements."

Option Explicit
Const subname = "b"
Execute subname
Sub b()
Response.write("sub b")
End sub

Or you could use:
Const subname = "b()"


 
Reply With Quote
 
gabba
Guest
Posts: n/a
 
      09-12-2006

"McKirahan" <(E-Mail Removed)> ha scritto nel messaggio

>> 'does exist something like this? or something like the javascript 'eval'
>> ?

>
> "Eval" exists in VBScript and is described as:
> "Evaluates an expression and returns the result."
>
> "Execute" will do what you want:
> "Executes one or more specified statements."


Perfect, really thank you.
this is what i'm lookink for.

I mentioned the javascript command eval() cause it's exactly the VbScript
Execute().

so...now I know that javascript eval and vbscript eval are false friends

gabba


 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      09-12-2006
gabba wrote:
> "McKirahan" <(E-Mail Removed)> ha scritto nel messaggio
>
>>> 'does exist something like this? or something like the javascript
>>> 'eval' ?

>>
>> "Eval" exists in VBScript and is described as:
>> "Evaluates an expression and returns the result."
>>
>> "Execute" will do what you want:
>> "Executes one or more specified statements."

>
> Perfect, really thank you.
> this is what i'm lookink for.
>
> I mentioned the javascript command eval() cause it's exactly the
> VbScript Execute().
>
> so...now I know that javascript eval and vbscript eval are false
> friends
>

And all three are evil.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
use one subroutine's variable value in another subroutine inside a module. king Perl Misc 5 04-29-2007 06:39 AM
variation on (?) call subroutine by reference Alison Bowes Perl 0 02-18-2005 05:39 PM
Tk: Call subroutine when MainWindow is realized? Josef Moellers Perl Misc 7 01-15-2005 01:00 AM
Call VBA subroutine from ASP WC Justice ASP General 1 09-27-2004 03:28 PM
How do I call sort with an anonymous subroutine stored in a hash ?? Casey Perl 3 01-30-2004 03:39 PM



Advertisments