0

Debugger によると、myCancelledNothing の値を持つ型 Newtonsoft.Json.Linq.Jtoken と呼ばれる変数があります。また、それを Object にキャストしましたが、これらの条件はすべて失敗します。私の質問は単純です:それがNothing/Null/False/Emptyかどうかを確認するにはどうすればよいですか?

これが私が試したことです。これらの条件はいずれも true と評価されません。

            If myCancelled Is Nothing Then
                'Doesn't come here
            End If
            If myCancelled = DBNull.Value.ToString Then
                'Doesn't come here
            End If
            If myCancelled = "null" Then
                'Doesn't come here
            End If
            If IsDBNull(myCancelled) Then
                'Doesn't come here
            End If
            If myCancelled Is DBNull.Value Then
                'Doesn't come here
            End If
            If String.IsNullOrEmpty(myCancelled) = True Then
                'Doesn't come here
            End If
            If myCancelled.ToString = "Nothing" Then
                'Runtime error
            End If
            If myCancelled = DBNull.Value Then
                'Runtime error
            End If
            If IsNothing(myCancelled) Then
                'Doesn't come here
            End If

私はVB.netを初めて使用するので、ポインタをいただければ幸いです。

編集

これは機能しましたが、誤検知を通過させます(myCancelledに値がある場合、条件は真です)

            If Not myCancelled Then
                ' It comes here
            End If
4

1 に答える 1

1

This is what worked. VB is hard to learn when you get used to Java, C#, etc.

If Not myCancelled.Equals("Y") Then
    ' It finally came here
End If
于 2015-12-23T20:32:08.500 に答える