运行-时间错误“438”:对象不支持此 属性 或方法 vba
Run-Time error '438': Object Doesn't support this property or method vba
我很难处理错误 438。我正在努力为集合中的每个员工节省 属性 的薪水。
Public Sub Click()
Dim employee As Collection
Set employee = New Collection
Dim n As Integer
Dim i As Integer
Dim E1 As Variant
Dim j As Integer
n = 528
Dim t As String
For i = 3 To n
t = "T" + CStr(i)
Set E1 = New clsEmployee
E1.salary = Sheets("A").Range(t).Value
Next i
End sub
如果 clsEmployee
没有 public .salary
属性,我可以想象得到发布代码的特定运行时错误的唯一方法。这可以通过更改声明来确认...
Dim E1 As Variant
...至:
Dim E1 As clsEmployee
在这种情况下,它将给出编译错误 "Method or data member not found" 而不是运行时错误。
解决方案是如果 属性 不存在则添加它,如果存在则将其设为 public。
我很难处理错误 438。我正在努力为集合中的每个员工节省 属性 的薪水。
Public Sub Click()
Dim employee As Collection
Set employee = New Collection
Dim n As Integer
Dim i As Integer
Dim E1 As Variant
Dim j As Integer
n = 528
Dim t As String
For i = 3 To n
t = "T" + CStr(i)
Set E1 = New clsEmployee
E1.salary = Sheets("A").Range(t).Value
Next i
End sub
如果 clsEmployee
没有 public .salary
属性,我可以想象得到发布代码的特定运行时错误的唯一方法。这可以通过更改声明来确认...
Dim E1 As Variant
...至:
Dim E1 As clsEmployee
在这种情况下,它将给出编译错误 "Method or data member not found" 而不是运行时错误。
解决方案是如果 属性 不存在则添加它,如果存在则将其设为 public。