VB Tutorial
Tools
Free Downloads
Free Link Directory

Basics
Data Types
Windows Forms
Buttons
Check Box
Text Box
Combo Box
Radio Buttons
Progress Bar
Color & Font Dialogs
Open & Save Dialogs
Process Control

More Complex Examples
Audio Player
Rotating Rectangle

 

Text Box Controls In Vb.Net

The main use of textboxes are to obtain data from the user. We all have filled in forms during application setups and more. The squares where we insert our User Names and Passwords are textboxes. Textboxes can also be locked so that the user can only view the data displayed in the textbox. Should you decide to use a textbox for Passwords, set the Password Char attribute to the character you want to be displayed. If you set the Password Char to "*", and enter the password "1234", the textbox will show "****".

We Can do a simple example to demonstrate how it works. Open a new project. Change the Forms Text attribute from "Form1" to "Please enter your password". Create a Textbox by double clicking on the Textbox Icon in the Tools window. A Textbox called TextBox1 will be created on the form. Follow the same procedure to create a Label, which by default will be called Label1. Change the Labels Text attribute to "Please Register". Also create a Button and change its text to "Submit". In the textbox attributes for TextBox1 set the Password Char to "*". Space the Controls as in the next figure.


Figure 5: Basic TextBox

Double click on your Form to go to the Load event. In the Load event enter "Me.AcceptButton = Button1".
Double click on your button to go to the buttons event handling. Enter the text "Label1.Text = "Thank you for Registering. Your Password is " & TextBox1.Text".
Double click on the TextBox and enter "Label1.Text = "Please Register". Your code should look something like the following.

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AcceptButton = Button1
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "Thank you for Registering. Your Password is " & TextBox1.Text
End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal ...
Label1.Text = "Please Register"
End Sub

End Class

Run the application and change the password a couple of times to see how the code works.
If you liked this article then Please Thumb This Up with a short review - Stumble It!
Continue to the next Page.

 


Email us at: info@pro2visual.com
 

Get your Website Listed on our Free Link Banner Directory
Advertise your site with your own unique link banner we will also provide text links to your site.

Popular Articles

Moving a borderless form in vb.net

ComboBox1.Items.Add

Link Progress Bar with Timer in vb.net

How to open a folder using the process control

Start Vb.net programming. No get rich quick scam

How to Convert the Date Format

Click here for Industry Leading Development Softwa