2016-11-06 29 views
1

私は以下のコードに誤りがあるようです。BC30451 t 'VARIABLE'は宣言されていません。保護レベルのためにアクセスできない可能性があります

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でFYI、その。)

答えて

2

あなたの変数がなくなっている「場合終了」、または「スコープ外の」ヒット一度ようにするには、if文の中に2つの変数を調光しています。 variable scopeに関するいくつかの調査を行う必要があります。コード内でこれを修正するには、最初に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 
+1

これは完全に機能します。ありがとう:) – TheDeibo

関連する問題