|  |  | 
              
              | 
                  | Title | Call a subroutine by name in VB6 | 
|---|
 | Keywords | subroutine, routine, VB6, CallByName | 
|---|
 | Categories | Software Engineering, Tips and Tricks | 
|---|
 |  | 
 |  | Use the CallByName function (VB6 only). |  | 
 |  
                | Private Sub Command1_Click()
    CallSubroutine "SubA"
End Sub
Private Sub Command2_Click()
    CallSubroutine "SubB"
End Sub
Private Sub CallSubroutine(ByVal sub_name As String)
    CallByName Me, sub_name, VbMethod
End Sub
Public Sub SubA()
    MsgBox "This is SubA"
End Sub
Public Sub SubB()
    MsgBox "This is SubB"
End Sub |  |  |  |   |  |  |  |  |