Excel 2010 VBA – 错误:对象variables或未设置块variables
我有一个自己的类(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”(来回),但是我仍然有同样的错误…
感谢提前回复。
铯
您需要创build一个实例并将其分配给Foo
;
Dim Foo as ClassFoo Set Foo = new ClassFoo
你需要实例化我相信尝试
Dim foo as new ClassFoo