Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated