-2

スレッドを使用してファイルから読み取り、コンテンツを処理しています。私は次のコードを持っています:

Dim line As String = Nothing
Dim result As String = Nothing
Dim solved As Boolean
While strReader.EndOfStream <> True
    SyncLock strReader
        line = strReader.ReadLine()
        result = "ERROR"
    End SyncLock
    solved = False
    While solved = False
        result = Process(line)
        If Not result.Contains("ERROR") Then
            solved = True
        End If
    End While
    //some code
End While

そしてそれは私にそのエラーを行に与えます:If Not result.Contains( "ERROR")Then

ラベル付きは問題なく動作しますが、コーディングには適していないと読みました。

このエラーを取り除くにはどうすればよいですか?私は何が間違っているのですか?

ありがとう!

4

1 に答える 1

1

エラーはほとんどすべてを物語っています

Process(line) 

null 値を返しています。Process()null 以外の値を返すように修正しました。

あるいは、これを行うことができます

If not result is nothing then 
  solved = not result.Contains("ERROR")
End if
于 2012-04-24T22:58:08.597 に答える