BC30451 'VARIABLE' 未声明。由于其保护级别,它可能无法访问
BC30451 'VARIABLE' is not declared. It may be inaccessible due to its protection level
我似乎对下面的代码有错误。
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
If My.Computer.FileSystem.FileExists("bin\php\php.exe") Then
Dim PHPRC As String = ""
Dim PHP_BINARY As String = "bin\php\php.exe"
Else
Dim PHP_BINARY As String = "php"
End If
If My.Computer.FileSystem.FileExists("PocketMine-MP.phar") Then
Dim POCKETMINE_FILE As String = "PocketMine-MP.phar"
Else
If My.Computer.FileSystem.FileExists("src\pocketmine\PocketMine.php") Then
Dim POCKETMINE_FILE As String = "src\pocketmine\PocketMine.php"
Else
MsgBox("Couldn't find a valid PocketMine-MP installation", MsgBoxStyle.Exclamation, "PocketMine-MP")
End If
End If
Process.Start("C:\Users\Damian\Desktop\Games\Pocketmine\Installer\PocketMine-MP\bin\mintty.exe", "-o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font='DejaVu Sans Mono' -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t 'PocketMine-MP' -i bin/pocketmine.ico -w max" & PHP_BINARY & "" & POCKETMINE_FILE & "" & "--enable-ansi")
End Sub
我一直收到这个错误
BC30451 'PHP_BINARY' 未声明。由于其保护级别,它可能无法访问。
BC30451 'POCKETMINE_FILE' 未声明。由于其保护级别,它可能无法访问。
我做错了什么?
(仅供参考,它在 Form1_Load 中只是出于测试原因。)
您在 if 语句中使两个变量变暗,所以一旦您点击 "end if",您的变量就会消失,或者 "out of scope"。你绝对应该对 variable scope 做一些研究......要在你的代码中解决这个问题,首先在 sub 内部但在你的 if 语句之外声明字符串。然后只需使用 if 语句来更改变量所包含的内容;这样,当您的流程调用出现时,变量将不会超出范围:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Dim PHP_BINARY As String = Nothing
Dim POCKETMINE_FILE As String = Nothing
If My.Computer.FileSystem.FileExists("bin\php\php.exe") Then
PHP_BINARY = "bin\php\php.exe"
Else
PHP_BINARY = "php"
End If
If My.Computer.FileSystem.FileExists("PocketMine-MP.phar") Then
POCKETMINE_FILE = "PocketMine-MP.phar"
Else
If My.Computer.FileSystem.FileExists("src\pocketmine\PocketMine.php") Then
POCKETMINE_FILE = "src\pocketmine\PocketMine.php"
Else
MsgBox("Couldn't find a valid PocketMine-MP installation", MsgBoxStyle.Exclamation, "PocketMine-MP")
End If
End If
Process.Start("C:\Users\Damian\Desktop\Games\Pocketmine\Installer\PocketMine-MP\bin\mintty.exe", "-o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font='DejaVu Sans Mono' -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t 'PocketMine-MP' -i bin/pocketmine.ico -w max" & PHP_BINARY & "" & POCKETMINE_FILE & "" & "--enable-ansi")
End Sub
我似乎对下面的代码有错误。
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
If My.Computer.FileSystem.FileExists("bin\php\php.exe") Then
Dim PHPRC As String = ""
Dim PHP_BINARY As String = "bin\php\php.exe"
Else
Dim PHP_BINARY As String = "php"
End If
If My.Computer.FileSystem.FileExists("PocketMine-MP.phar") Then
Dim POCKETMINE_FILE As String = "PocketMine-MP.phar"
Else
If My.Computer.FileSystem.FileExists("src\pocketmine\PocketMine.php") Then
Dim POCKETMINE_FILE As String = "src\pocketmine\PocketMine.php"
Else
MsgBox("Couldn't find a valid PocketMine-MP installation", MsgBoxStyle.Exclamation, "PocketMine-MP")
End If
End If
Process.Start("C:\Users\Damian\Desktop\Games\Pocketmine\Installer\PocketMine-MP\bin\mintty.exe", "-o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font='DejaVu Sans Mono' -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t 'PocketMine-MP' -i bin/pocketmine.ico -w max" & PHP_BINARY & "" & POCKETMINE_FILE & "" & "--enable-ansi")
End Sub
我一直收到这个错误
BC30451 'PHP_BINARY' 未声明。由于其保护级别,它可能无法访问。
BC30451 'POCKETMINE_FILE' 未声明。由于其保护级别,它可能无法访问。
我做错了什么?
(仅供参考,它在 Form1_Load 中只是出于测试原因。)
您在 if 语句中使两个变量变暗,所以一旦您点击 "end if",您的变量就会消失,或者 "out of scope"。你绝对应该对 variable scope 做一些研究......要在你的代码中解决这个问题,首先在 sub 内部但在你的 if 语句之外声明字符串。然后只需使用 if 语句来更改变量所包含的内容;这样,当您的流程调用出现时,变量将不会超出范围:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Dim PHP_BINARY As String = Nothing
Dim POCKETMINE_FILE As String = Nothing
If My.Computer.FileSystem.FileExists("bin\php\php.exe") Then
PHP_BINARY = "bin\php\php.exe"
Else
PHP_BINARY = "php"
End If
If My.Computer.FileSystem.FileExists("PocketMine-MP.phar") Then
POCKETMINE_FILE = "PocketMine-MP.phar"
Else
If My.Computer.FileSystem.FileExists("src\pocketmine\PocketMine.php") Then
POCKETMINE_FILE = "src\pocketmine\PocketMine.php"
Else
MsgBox("Couldn't find a valid PocketMine-MP installation", MsgBoxStyle.Exclamation, "PocketMine-MP")
End If
End If
Process.Start("C:\Users\Damian\Desktop\Games\Pocketmine\Installer\PocketMine-MP\bin\mintty.exe", "-o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font='DejaVu Sans Mono' -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t 'PocketMine-MP' -i bin/pocketmine.ico -w max" & PHP_BINARY & "" & POCKETMINE_FILE & "" & "--enable-ansi")
End Sub