I have a StringBuilder named "sb", and I want to make a timer update a TextBox named "StatusBox"'s text to match sb.ToString. My current code, however, throws the following error:
Error BC30451: 'sb' is not declared. It may be inaccessible due to its protection level.
The current code is below:
Imports System.Net
Imports System.Text
Imports System.IO
Imports System.IO.Compression
Public Class MainForm
Public Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim DefaultLocation As New Point(489, 424)
Dim CheckingLocation As New Point(438, 424)
Dim ErrorLocation As New Point(319, 424)
StatusLabel.Location = DefaultLocation
StatusBox.Hide()
If CheckForInternetConnection() = False Then
StatusBox.Hide()
StatusLabel.Show()
StatusLabel.Text = "Either the AppVeyor is down, or you have no internet connectivity."
StatusLabel.Location = ErrorLocation
StatusBar.Image = RPCS3_Updater.My.Resources._Error
Else
StatusLabel.Text = "Checking for updates..."
StatusLabel.Location = CheckingLocation
StatusBar.Image = RPCS3_Updater.My.Resources.Checking
StatusBox.Show()
StatusLabel.Hide()
Dim appPath As String = Application.StartupPath()
Dim sb = New StringBuilder()
Dim psi = New ProcessStartInfo() With
{
.WorkingDirectory = appPath,
.FileName = appPath.ToString + "\Resources\GetRPCS3.bat",
.CreateNoWindow = True,
.RedirectStandardOutput = True,
.RedirectStandardInput = True,
.UseShellExecute = False
}
Dim pSpawn = New Process()
pSpawn.StartInfo = psi
AddHandler pSpawn.OutputDataReceived, Function(senderA, args) sb.AppendLine(args.Data)
pSpawn.Start()
pSpawn.BeginOutputReadLine()
StatusBox.Text = sb.ToString()
StatusTimer.Enabled = True
pSpawn.WaitForExit()
StatusBox.Text = sb.ToString()
If pSpawn.HasExited Then
Dim appPath1 As String = Application.StartupPath()
Dim zipPath As String = Directory.GetFiles(appPath1 + "\Resources").First.ToString
Dim extractPath As String = ""
ZipFile.ExtractToDirectory(zipPath, appPath1 + "\Resources\RPCS3")
End If
End If
End Sub
Public Shared Function CheckForInternetConnection() As Boolean
Try
Using client = New WebClient()
Using stream = client.OpenRead("https://ci.appveyor.com/project/rpcs3/rpcs3/build/artifacts")
Return True
End Using
End Using
Catch
Return False
End Try
End Function
Public Sub StatusTimer_Tick(sender As Object, e As EventArgs) Handles StatusTimer.Tick
StatusBox.Text = sb.ToString()
End Sub
End Class