Blank textbox shows message

lucky12341

Board Regular
Joined
Nov 4, 2005
Messages
121
I am working on a school project and am new to the computer sciences field and VB.Net. I almost have completed this assignment but I cannot seem to figure something out after doing alot of research and attempting the problem for awhile.

I need my userform to check to make sure the text box (nametxt) is not blank whenever a user does anything. If anyone needs example of my code let me know, I just cannot get a msgbox to show when the text box is blank.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Why not just test for it:

<font face=Tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> nametxt_Exit(<SPAN style="color:#00007F">ByVal</SPAN> Cancel <SPAN style="color:#00007F">As</SPAN> MSForms.ReturnBoolean)
    <SPAN style="color:#00007F">If</SPAN> nametxt.Text = "" <SPAN style="color:#00007F">Then</SPAN>
        MsgBox "Name must be filled in"
        nametxt.SetFocus
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

I used the Exit event in case someone tries to tab through it, but that may not be the trigger you want.

HTH,

Smitty
 

lucky12341

Board Regular
Joined
Nov 4, 2005
Messages
121
Well I need the user to be able to fiddle with anything on the userform. Specifically though when they click on one of the radiobuttons that is supposed to display something, I want it to make sure the nametxt textbox is not blank. I didnt know if there was a general way I can do this or if I have to link it to each of the 4 radio buttons etc.

I apologize I know its a retarded and sinple school project but I love programming and I get frustrated becuase I haven't found a way to mutate the code yet.

UPDATE- I got it working, thank you very much for the help.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
I want it to make sure the nametxt textbox is not blank

You need to figure out what trigger you want to test for an entry in the TB.

Smitty
 

Forum statistics

Threads
1,136,876
Messages
5,678,288
Members
419,753
Latest member
Sallylwy

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
Top