あなたの目的は、あなたは、単にInt32.TryParseを使用することができ、あなたのテキストボックス内の値を合計して整数に変換できないテキストボックスを無視する場合。
例外をスローせずにテキストを整数に変換できない場合は、変数を0に設定します。
' In place of your textboxes
Dim x1 As String = "2"
Dim x2 As String = Nothing
Dim x3 As String = "5"
Dim a, b, c As Integer
Int32.TryParse(x1, a)
Int32.TryParse(x2, b)
Int32.TryParse(x3, c)
Dim result = a + b + c
Console.WriteLine(result)
間違った入力をユーザーに知らせるために、テキストボックスのテキストに「0」の文字列を書きたい場合は代わりに、あなたは再びInt32.TryParse
を使用して、テキストボックスを一つずつ確認する必要があり
Dim value1 as Integer
if Not Int32.TryParse(a.Text, value1) Then
a.Text = "0"
End If
' Here the variable value1 contains the converted value or zero.
' repeat for the other textboxes involved