所以,我有以下的VB代碼: 「txtVern」如何在VB中的代碼中的其他位置調用變量?
Try
Using verSR As New StreamReader(appDataVersionLoc)
Dim txtVern As String
txtVern = verSR.ReadToEnd()
End Using
Catch ex As Exception
Dim verFile As System.IO.FileStream
verFile = System.IO.File.Create(appDataVersionLoc)
My.Computer.FileSystem.WriteAllText("appDataVersionLoc", "0.0.0.0", True)
MessageBox.Show("Version file missing/corrupt, created a new one.")
End Try
見該變量稱爲我試圖在try-end try塊外的代碼中的其他地方使用它。 差不多這樣的:
Try
Using verSR As New StreamReader(appDataVersionLoc)
Dim txtVern As String
txtVern = verSR.ReadToEnd()
End Using
Catch ex As Exception
Dim verFile As System.IO.FileStream
verFile = System.IO.File.Create(appDataVersionLoc)
My.Computer.FileSystem.WriteAllText("appDataVersionLoc", "0.0.0.0", True)
MessageBox.Show("Version file missing/corrupt, created a new one.")
End Try
blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah
Dim currentversion As String = txtVern
現在,我是一個完整的VB小白,而我得到這個錯誤:
'txtVern' is not declared. It may be inaccessible due to its protection level.
我該如何解決這個問題? 謝謝!
謝謝!這工作! – Dubstaphone