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 Send an Email via G-Mail in Visual Basic 6
Visual Basic 6 (VB6) is Microsoft's take on the classic Basic computer programming language. The VB6 version of the language and the...
How to Create a Text Box With HTML Programming
Text boxes are usually used to enter names and addresses, but you can add text boxes to your site to allow viewers...
How to Check for Null Value in Visual Basic
In computer programming languages, "null" means nothing. It is different from any other value, including a blank string that actually contains the...
How to Insert Text Boxes With VBA Code in Excel
The text box is the element on a form that allows you to enter data in the user application. You can use...
How to Check if a Textbox Input Is Numeric in Visual Basic
You can significantly improve the performance of your Visual Basic application by not having to check every character entered by the user....
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. One such example is the ability to convert data...