Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling functions

Status
Not open for further replies.

bronc

Instructor
Aug 28, 2003
145
GB

Hello. Is it possible to call a function using a variable name?
as in :

Private Sub CommandButton1_Click()
Dim var
var = "eddo"
Call var

Sub eddo()
MsgBox "eddo"
End Sub
 
Which application ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

boy that was quick. thanks
well that's Excel VBA but i expect its generic.

 
Have a look at the Application.Run method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I was looking for something like that awhile ago and couldn't find it. I tried it out and it works. Here was very simple test. Executing test1 produces the "hello" message box
Code:
Sub test1()
 Dim subname As String
  subname = "test2"
  Application.Run (subname)
 End Sub

Sub test2()
MsgBox ("hello")
End Sub
 
That is REALLY cool as they say. Thanks a lot. (Of course Sub test2() needs to be in a code module.)

I was thinking in terms of allocating a different pointer to a function as you do in C++ 'cept pointers don't exist in VB so that's great. Thanks again. Thanks PHV as well.
 
>'cept pointers don't exist in VB so that's great

They do ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top