Article ID: 186143
Article Last Modified on 7/13/2004
Option Explicit
Private MyPropValue As Integer
Public Function Multiply(x As Integer, y As Integer) As Integer
Multiply = x * y
End Function
Public Property Get MyProperty() As Variant
MyProperty = MyPropValue
End Property
Public Property Let MyProperty(ByVal vNewValue As Variant)
MyPropValue = vNewValue
End Property
Option Explicit
Private Sub Form_Click()
Dim myclass As New Class1
Dim sum As Integer
Dim prop As Integer
' Example of calling a method with CallByName
' equivalent to -- sum = myclass.Multiply(12, 12)
sum = CallByName(myclass, "Multiply", VbMethod, 12, 12)
MsgBox sum
' Example of a property let with CallByName
' equivalent to -- myclass.MyProperty = 5
CallByName myclass, "MyProperty", VbLet, 5
' Example of a property get with CallByName
' equivalent to -- prop = myclass.MyProperty
prop = CallByName(myclass, "MyProperty", VbGet)
MsgBox prop
End Sub
Additional query words: kbDSupport kbDSD kbVBA kbVBp600 kbVBp
Keywords: kbhowto KB186143