2011-05-23 55 views
0

是否可以調用存儲在前一個子字符串中的字符串或對象? 下面的代碼給你一個想法,我想要做什麼。重新調用前一個子字符串/對象

Sub StoreUserData() 
Dim StorName as Object 
End 

Sub WriteUserFile() 
'Recall StorName here 
End Sub 

回答

1

你需要將它做成一個字段:

Dim StorName as Object 

Sub StoreUserData() 
    'Do stuff with StoreName 
End 

Sub WriteUserFile() 
'Recall StorName here 
End Sub 

如果一個方法中聲明,它是一個局部變量和方法外不可見。

我建議閱讀關於Scope in Visual Basic

0

局部變量只能在其各自的代碼塊中訪問。爲了能夠訪問它,你將不得不擴大其範圍:

Class MyClass 

    Dim storName as Object 

    Sub StoreUserData() 
     storName = something 
    End Sub 

    Sub WriteUserFile() 
     ' Use storName here 
    End Sub 

End Class 
相關問題