Visual Basic is an event-driven programming language and integrated development environment developed and deployed by Microsoft Corporation. Visual Basic originated from BASIC. The language conforms to Microsoft's Component Object Model (COM) software development standards. The language makes heavy use of reusable code, referred to as active X controls and objects. Using the VB programming environment, users can easily drag and drop controls into their VB programs and have access to their events, properties and attributes. Placing a textbox control into your VB program and checking to see if it's empty or not takes but a few simple steps.
Open Visual Basic.NET.
Select "Windows Application" in the "New Project" window and give your program a name. Click "OK." A default visual basic form1 should now be created and displayed on your screen.
Click on "Button" from the toolbar and draw it onto the form.
Click on "Textbox" from the toolbar and draw it onto the form.
Double-click on the "Button" object. That will open the code area for the button.
Enter the following code in between the Button1's click event sub procedure.
Type: If TextBox1.Text="" then MsgBox("This text box is empty") Else Msgbox("This text box is not empty").
Your code should look like the following:
Public Class Form1
Private Sub Button1Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) _
If TextBox1.Text = "" Then
MsgBox ("the text box is empty")
MsgBox ("the text box is not empty")
The preceding code Textbox1.text="" checks the value in the textbox by using an if-else statement to evaluate it for a value.
Press "F5" on your keyboard to run the program.
Enter some information in the textbox and press the button. You should get a pop-up message box with the words "The Text Box Is Not Empty" in the middle of it.
Erase the information in the text box and press the button. You should get a pop-up message box with the words "The Text Box Is Empty" in the middle of it.
How to Check if a Textbox Input Is Numeric in Visual Basic
How to Check if a Textbox Input Is Numeric in Visual Basic. ... How to Convert a String to Integers in VB.NET;...
How to Check for Null Value in Visual Basic
How to Check for Null Value in Visual Basic. ... If you wish to ensure the variable is not Null, you can...
How to Insert Text Boxes With VBA Code in Excel
You can use input from the text box in your Visual Basic for Application ... An Excel VBA text box is an...
How to Create a Text Box With HTML Programming
HTML, or hypertext markup language, is a computer language that is used to create web pages. Websites and web pages are written...
How to Send an Email via G-Mail in Visual Basic 6
How to Send an Email via G-Mail in Visual Basic 6. Visual Basic 6 (VB6) is Microsoft's take on the ... ("CDO.Message")...
How to Convert a Textbox to a Number in Visual Basic
Microsoft's Visual Basic contains some powerful functions that make the programmer's life easier. ... How to Count Words in a Textbox in...