所以,我有以下 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
看到那个名为“txtVern”的变量了吗?我正在尝试在 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' 未声明。由于其保护级别,它可能无法访问。
我怎样才能解决这个问题?谢谢!