Search code examples
excelvbatextbox

VBA Check If Textbox Is Null then send message


first end second if statments working (combobox and textbox <10 ) but third is not(null value). Why?

Private Sub CommandButton1_Click()
If ComboBox1.ListIndex = -1 Then
MsgBox "bla"
Exit Sub
End If
If CDbl(TextBox1.Text) < 10 Then
    MsgBox "bla!"
Exit Sub
End If
If (TextBox1.Value = Null) Then
    MsgBox "bla!"
End If
Exit Sub

Solution

  • I think there is logical error when ı try to reverse if condition between null and smaller its worked. Here is the correct form;

    Private Sub CommandButton1_Click()
    If ComboBox1.ListIndex = -1 Then
    MsgBox "bla"
    Exit Sub
    End If
    End If
    If TextBox1.Text= "" Then
        MsgBox "bla!"
    End If
    Exit Sub
    If CDbl(TextBox1.Text) < 10 Then
        MsgBox "bla!"
    Exit Sub