如标题所示,这两个都是声明变量,但是我在一个程序中看到这样一段代码:
Public Property Get Locked(RowIndex As Integer, ColIndex As Integer) As Boolean
Locked = a_RowColLock(ColIndex, RowIndex)
End Property
Public Property Let Locked(RowIndex As Integer, ColIndex As Integer, blnLock As Boolean)
With m_MsFlexGrid_Pack
a_RowColLock(ColIndex, RowIndex) = blnLock
End With
End Property
vb 变量声明Public Property Get 和Public Property let的 区别
如标题所示,这两个都是声明变量,但是我在一个程序中看到这样一段代码: Public Property Get Locked(RowIndex As Integer, ColIndex As Integer) As Boolean Locked = a_RowColLock(ColIndex, RowIndex) End Property Public Property Let Locked(RowIndex As Integer, ColIndex As Integer, blnLock As
[Quote=引用楼主 piaoxie268 的回复:]
如标题所示,这两个都是声明变量,但是我在一个程序中看到这样一段代码:
Public Property Get Locked(RowIndex As Integer, ColIndex As Integer) As Boolean
Locked = a_RowColLock(ColIndex, RowIndex)
End Property
Dim c As Class1 '假定这就是你的类名
Dim b As Boolean
Set c = New Class1
'下面这个属性赋值调用 Property Let,如果类中没有 Property Let,下面语句出错,即属性是只读的。
c.Locked(1,1) = True
'下面这个属性取值调用 Property Get,如果类中没有 Property Get,下面语句出错,即属性是不可读取的。
b = c.Locked(1,1)