user793468
user793468

Reputation: 4966

How do I check for null value in an excel userform textbox?

Why does the following not work?

If IsNull(Me.TextBox1.Value) = True Then

MsgBox "Null"

Else

MsgBox "Not Null"

End If

Here, I don't enter any value in "TextBox1" but it still passes the first if loop and displays "Not Null"

How do I check for null values?

Upvotes: 2

Views: 23775

Answers (3)

Suryadi
Suryadi

Reputation: 1

I think, the default value of blank textbox is ""

Try:

If (Me.TextBox1.Value) = "" Then 
   MsgBox "Null" 
Else 
  MsgBox "Not Null"  
End If  

Lets see if it is working

Upvotes: 0

HRgiger
HRgiger

Reputation: 2790

I don't have Excel on my computer, but can you try Me.TextBox1.Text instead of Me.TextBox1.Value.

Upvotes: 0

Bruno Leite
Bruno Leite

Reputation: 1477

Try

If me.textbox1= vbNullString then

[]'s

Upvotes: 4

Related Questions