你好我试图在vb中创建一个类,并在尝试实例化该类时没有任何值
Private lat As Double
Private lon As Double
Public Property Get Longitud() As Double
Longitud = lon
End Property
Public Property Get Latitud() As Double
Latitud = lat
End Property
Public Property Let Longitud(ByVal longi As Double)
Longitud = lon
End Property
Public Property Let Latitud(ByVal lati As Double)
Latitud = lat
End Property
当我试图实例
时Dim cord As Coordenadas
Set cord = New Coordenadas
cord.Latitud = 40.30416667
cord.Longitud = 0.22583333
我看不到电话线的任何变化
答案 0 :(得分:2)
您的Let属性未正确分配您作为参数传递的值。 它应该如下:
Private lon As Double
'
Public Property Let Longitud(ByVal longi As Double)
lon = longi
End Property
Let
应该将值赋给私有变量(Lon),Get
应该检索存储在该变量中的值。
另外,如果您为私人财产提供特殊后缀,它会对您有所帮助。例如pLon和pLat。这种方式更容易从参数和属性中识别变量。