Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Is there "pointer to a function" in VBA

In many languages you can work with pointers to functions, allowing you to
"parameterize" your code with regard to the functions that get called.
Is there a facility to do this in VBA? For example, I'd like to do something
like this:

Sub functionOne( ByRef theFunction())
....
theFunction()
....
End Sub


TIA

Ed


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Is there "pointer to a function" in VBA

You can do it with th ename of the procedure as a String:

Sub Sub2(SubName As String)
Application.Run SubName
End Sub

Sub Sub1()
Debug.Print "Hello, World!"
End Sub

In the Immediate Window:

Sub2("Sub1")
Hello, World!

--

Vasant

"Jag Man" wrote in message
...
In many languages you can work with pointers to functions, allowing you

to
"parameterize" your code with regard to the functions that get called.
Is there a facility to do this in VBA? For example, I'd like to do

something
like this:

Sub functionOne( ByRef theFunction())
...
theFunction()
...
End Sub


TIA

Ed




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Is there "pointer to a function" in VBA

If xl2000 or later, look at Addressof in help and see if that is what you
want. Generally, VB does not do pointers.

--
Regards,
Tom Ogilvy

Jag Man wrote in message
...
In many languages you can work with pointers to functions, allowing you

to
"parameterize" your code with regard to the functions that get called.
Is there a facility to do this in VBA? For example, I'd like to do

something
like this:

Sub functionOne( ByRef theFunction())
...
theFunction()
...
End Sub


TIA

Ed




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Is there "pointer to a function" in VBA

Thanks, Vasant . I think the syntax is:
Application.Run(SubName, arg, arg)

I got a compiler syntax error with
Application.Run SubName(arg, arg)

Ed



"Vasant Nanavati" <vasantn *AT* aol *DOT* com wrote in message
...
You can do it with th ename of the procedure as a String:

Sub Sub2(SubName As String)
Application.Run SubName
End Sub

Sub Sub1()
Debug.Print "Hello, World!"
End Sub

In the Immediate Window:

Sub2("Sub1")
Hello, World!

--

Vasant

"Jag Man" wrote in message
...
In many languages you can work with pointers to functions, allowing you

to
"parameterize" your code with regard to the functions that get called.
Is there a facility to do this in VBA? For example, I'd like to do

something
like this:

Sub functionOne( ByRef theFunction())
...
theFunction()
...
End Sub


TIA

Ed






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
Text "comparison" operator for "contains" used in an "IF" Function Pawaso Excel Worksheet Functions 4 April 4th 23 11:35 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
how do i make a "dashboard style" chart (semi circle & pointer) SamanthaGaszczak Charts and Charting in Excel 1 November 16th 05 09:30 PM
Change mouse to "busy" pointer when I bring up a form Scott Lyon Excel Programming 4 September 5th 03 03:56 PM


All times are GMT +1. The time now is 07:01 PM.

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

About Us

"It's about Microsoft Excel"