IsEmpty on textbox does not work - what to use instead

webster188

New Member
Joined
Oct 20, 2010
Messages
31
Hi,

I have created a very simple userform with one textbox and a "back" and "next" commandbutton.
The "next" commandbutton only becomes active when the textbox is not empty.
Unfortunately, even when the textbox is empty, the commandbutton is alway enabled.
I found out that textbox.value="" is not considered as Empty.

What syntax should I use instead to make this work?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Does not change a thing

Syntax used is

Code:
If IsEmpty(My.textbox.text)=false then
' commandbutton active
End if

Even if the textbox is empty, commandbutton active is always executed.
 
Upvote 0
Code:
If IsEmpty(M[B][COLOR="Red"]e[/COLOR][/B].Textbox) then
' commandbutton active
End if
 
Upvote 0
This worked for me...

Code:
Private Sub TextBox1_Change()
    CommandButton1.Enabled = TextBox1.Value <> vbNullString
End Sub
 
Upvote 0
Instead of vbNullString you could use ""
 
Upvote 0
Since there is always confusion about vbNullString, I check whether the length of the text is zero:

If Len(Me.TextBox1.Text) = 0 Then
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top