You can use Integer.TryParse to determine if the value is a proper integer:
Dim x As Integer
If Integer.TryParse(TextBox1.Text, x) Then
MessageBox.Show(x)
Else
MessageBox.Show("'" + TextBox1.Text + "' is not a valid number")
End If
If you need to just check for a blank string, you can use String.IsNullOrEmpty on the text itself:
If String.IsNullOrEmpty(TextBox1.Text) Then
MessageBox.Show("String is empty")
End If
Val
is a legacy function leftover from VB6 days and has some weird behavior if you don't know about it. I avoid it for this reason. For example, take the following cases and the output they generate:
MessageBox.Show(Val("")) '0
MessageBox.Show(Val("5")) '5
MessageBox.Show(Val("5e3")) '5000
MessageBox.Show(Val("5xyz")) '5