Listing 1

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
 System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
   If Char.IsNumber(e.KeyChar) = False Then
        MsgBox("Enter Only Numbers")
   End If
End Sub

Listing 2

Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
 System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
    If IsDate(TextBox1.Text) = False Then
        e.Cancel = True
        ErrorProvider1.SetError(TextBox1, "Not A
        Valid Date")
    ElseIf IsDate(TextBox1.Text) = True Then
        ErrorProvider1.SetError(TextBox1, "")
    End If
End Sub

Listing 3

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
 System.EventArgs) Handles Button1.Click
    Dim MissingField As Boolean
    MissingField = False
    If TextBox1.Text = "" Then
        MissingField = True
        ErrorProvider1.SetError(TextBox1,
        "Required Field")
    Else : ErrorProvider1.SetError(TextBox1, "")
    End If
    If TextBox2.Text = "" Then
        MissingField = True
        ErrorProvider1.SetError(TextBox2,
        "Required Field")
    Else : ErrorProvider1.SetError(TextBox2, "")
    End If
    If MissingField = False Then
        ' Proceed with program code
    End If
End Sub