Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleInvoke a function by name using CallByName
KeywordsCallByName, execute, invoke, call, function, subroutine
CategoriesTips and Tricks, Software Engineering
 
When the user clicks the Evaluate button, the program uses CallByName to invoke the function selected by the cboMethod ComboBox.
 
Private Sub cmdEvaluate_Click()
Dim result As Variant

    result = CallByName(Me, cboMethod.Text, VbMethod, _
        txtParameter)
    lblResult.Caption = Format$(result)
End Sub

Public Function Root(ByVal X As Single)
    Root = Sqr(X)
End Function

Public Function Square(ByVal X As Single)
    Square = X * X
End Function

Public Function Triple(ByVal X As Single)
    Triple = 3 * X
End Function
 
Note that CallByName is slower than invoking a function directly.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated