Calling a sub or function using a variable through another sub or function 
Author Message
 Calling a sub or function using a variable through another sub or function

I know, the title is a bit confusing.  This is what I'm trying to do:

Create an onClick sub or function that will accept the name of a second sub
or function to be executed as a variable parameter.  Is This possible?

Sample HTML:
<input type="button" value="Click Me" name="B1"
onClick=subClick("doFunction")>

' Sub called by the onClick event of the button

Sub subClick(callThis)
    ' Do some stuff here

    ' Call sub or function specified in the onClick event in the HTML
    Call callThis

End Sub

' Second sub passed from the

Sub doFunction()
    ' This is the sub specified by the HTML in the onClick event

    ' Do something else here
End Sub

Hopefully, somebody has tried this before and can shed some light on this
poor script junkie.  :)

    - Glen



Tue, 22 Apr 2003 03:00:00 GMT  
 Calling a sub or function using a variable through another sub or function

VBScript 5.0 or higher...

Sub subClick(callThis)
    ' Do some stuff here

    ' Call sub or function specified in the onClick event in the HTML
    Execute callThis

End Sub

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I know, the title is a bit confusing.  This is what I'm trying to do:

> Create an onClick sub or function that will accept the name of a second sub
> or function to be executed as a variable parameter.  Is This possible?

> Sample HTML:
> <input type="button" value="Click Me" name="B1"
> onClick=subClick("doFunction")>

> ' Sub called by the onClick event of the button

> Sub subClick(callThis)
>     ' Do some stuff here

>     ' Call sub or function specified in the onClick event in the HTML
>     Call callThis

> End Sub

> ' Second sub passed from the

> Sub doFunction()
>     ' This is the sub specified by the HTML in the onClick event

>     ' Do something else here
> End Sub

> Hopefully, somebody has tried this before and can shed some light on this
> poor script junkie.  :)

>     - Glen



Tue, 22 Apr 2003 03:00:00 GMT  
 Calling a sub or function using a variable through another sub or function

IE4+

Sub subClick(callThis)
    ' Do some stuff here

    ' Call sub or function specified in the onClick event in the HTML
    window.execScript callThis, "VBScript"

End Sub

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:

> I know, the title is a bit confusing.  This is what I'm trying to do:

> Create an onClick sub or function that will accept the name of a second sub
> or function to be executed as a variable parameter.  Is This possible?

> Sample HTML:
> <input type="button" value="Click Me" name="B1"
> onClick=subClick("doFunction")>

> ' Sub called by the onClick event of the button

> Sub subClick(callThis)
>     ' Do some stuff here

>     ' Call sub or function specified in the onClick event in the HTML
>     Call callThis

> End Sub

> ' Second sub passed from the

> Sub doFunction()
>     ' This is the sub specified by the HTML in the onClick event

>     ' Do something else here
> End Sub

> Hopefully, somebody has tried this before and can shed some light on this
> poor script junkie.  :)

>     - Glen



Tue, 22 Apr 2003 03:00:00 GMT  
 Calling a sub or function using a variable through another sub or function

That's the ticket!  Thank you.

    - Glen


Quote:
> VBScript 5.0 or higher...

> Sub subClick(callThis)
>     ' Do some stuff here

>     ' Call sub or function specified in the onClick event in the HTML
>     Execute callThis

> End Sub

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --




- Show quoted text -

Quote:
> > I know, the title is a bit confusing.  This is what I'm trying to do:

> > Create an onClick sub or function that will accept the name of a second
sub
> > or function to be executed as a variable parameter.  Is This possible?

> > Sample HTML:
> > <input type="button" value="Click Me" name="B1"
> > onClick=subClick("doFunction")>

> > ' Sub called by the onClick event of the button

> > Sub subClick(callThis)
> >     ' Do some stuff here

> >     ' Call sub or function specified in the onClick event in the HTML
> >     Call callThis

> > End Sub

> > ' Second sub passed from the

> > Sub doFunction()
> >     ' This is the sub specified by the HTML in the onClick event

> >     ' Do something else here
> > End Sub

> > Hopefully, somebody has tried this before and can shed some light on
this
> > poor script junkie.  :)

> >     - Glen



Tue, 22 Apr 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Returning sub or function name within a specific sub or function

2. Local function/sub inside function/sub

3. execute a variable as a function/sub procedure (like eval function in java(script))

4. Calling a function/sub when a variable holds the name

5. Calling Functions or Subs with a variable

6. Calling functions/subs using the string title - possible?

7. calling the right function or sub

8. Call Sub functions with buttons

9. HOWTO: Call JavaScript function from inside a VBScript Sub

10. calling a Javascript function from and asp Sub Routine

11. Calling a sub or function

12. Passing arrays from a server-function/sub to a server -variable

 

 
Powered by phpBB® Forum Software