'Class1代码 Private nmA As Variant Public Property Get aaa() As Variant aaa = nmA End PropertyPublic Property Let aaa(ByVal vNewValue As Variant) nmA = vNewValue End Property--------------------- '窗体代码 Dim objN As Class1 Private Sub Form_Load() Set objN = New Class1 End SubPrivate Sub Command1_Click() objN.aaa = InputBox("请输入") End Sub Private Sub Command2_Click() MsgBox objN.aaa End Sub
let 设置非对象属性
get 只读
Private nmA As Variant
Public Property Get aaa() As Variant
aaa = nmA
End PropertyPublic Property Let aaa(ByVal vNewValue As Variant)
nmA = vNewValue
End Property---------------------
'窗体代码
Dim objN As Class1
Private Sub Form_Load()
Set objN = New Class1
End SubPrivate Sub Command1_Click()
objN.aaa = InputBox("请输入")
End Sub
Private Sub Command2_Click()
MsgBox objN.aaa
End Sub