3

我有一个自己的类(ClassFoo),它有一个简单的属性(pName),我无法设置它,因为我总是得到错误......

Class Modules - ClassFoo
---
Public pName as String

Public Property Let Name(Value as String)
   pName = Value
End Property
----
Somewhere else in the ModuleX
...
Dim Foo as ClassFoo
Foo.Name = "foo" <- throws error 
Foo.pName = "foo" <- throws error 

或者

With Foo
.pName = "foo" <- throws error 
End With 

我将“Instancing”类从“Private”更改为“PublicNotCreatable”(来回)但我仍然有同样的错误......

感谢您提前回复。

CS

4

2 回答 2

8

您需要创建一个实例并将其分配给它Foo

Dim Foo as ClassFoo
Set Foo = new ClassFoo
于 2013-01-04T16:04:31.193 回答
2

你需要实例化它我相信尝试

 Dim foo as new ClassFoo
于 2013-01-04T16:04:47.313 回答