问题描述
|
是否可以调出存储在先前子项中的字符串或对象?
以下代码为您提供了有关我要做什么的想法。
Sub StoreUserData()
Dim StorName as Object
End
Sub WriteUserFile()
\'Recall StorName here
End Sub
解决方法
您需要将其放入字段:
Dim StorName as Object
Sub StoreUserData()
\'Do stuff with StoreName
End
Sub WriteUserFile()
\'Recall StorName here
End Sub
如果在方法内声明,则它是局部变量,在方法外不可见。
我建议阅读有关Visual Basic中的范围的信息。
,局部变量只能在其各自的代码块中访问。为了能够访问它,您必须像下面这样扩大它的范围:
Class MyClass
Dim storName as Object
Sub StoreUserData()
storName = something
End Sub
Sub WriteUserFile()
\' Use storName here
End Sub
End Class