Vb.net BC30451和#x9';变量';未声明。由于其保护级别,可能无法访问
我似乎对下面的代码有错误Vb.net BC30451和#x9';变量';未声明。由于其保护级别,可能无法访问,vb.net,windows,mintty,Vb.net,Windows,Mintty,我似乎对下面的代码有错误 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 = "
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_二进制”。由于其保护级别,可能无法访问 BC30451未声明“POCKETMINE_文件”。由于其保护级别,可能无法访问 我做错了什么
(仅供参考,仅出于测试原因,它处于Form1_Load中。)您正在调暗if语句中的两个变量,因此一旦您点击“end if”,您的变量将消失,或“超出范围”。你绝对应该对……做些研究。。。要在代码中解决这个问题,首先在子语句内部、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