VB.Net provides several mechanisms for gathering input in a program. A TextBox control is used to display, or accept as input, a single line of text.
VB.Net programmers make extensive use of the TextBox control to let the user view or enter large amount of text. A text box object is used to display text on a form or to get user input while a VB.Net program is running. In a text box, a user can type data or paste it into the control from the clipboard.
For displaying a text in a TextBox control , you can code like this.
You can also collect the input value from a TextBox control to a variable like this way.
VB.Net TextBox Properties
You can set TextBox properties through Property window or through program. Normally Property window is located under the solution explorer. You can open Properties window by pressing F4 or right click on a control and select Properties menu item.
The below code set a textbox width as 150 and height as 25 through source code.
Background Color and Foreground Color
You can set Textbox background color and foreground color through property window, also you can set it programmatically.
You can set 3 different types of border style for textbox in vb.net, they are None, FixedSingle and fixed3d.
VB.Net TextBox Events
TextBox Keydown event
Keydown event occurs when a key is pressed while the control has focus.
TextChanged Event is raised if the Text property is changed by either through program modification or user input.
VB.Net Textbox Maximum Length
Maximum Length property sets the maximum number of characters or words the user can input into the text box control. That means you can limit the user input by this property.
How to ReadOnly Textbox
when a program wants to prevent a user from changing the text that appears in a text box, the program can set the controls Readonly property is to True.
Multiline TextBox in vb.net
By default TextBox accept single line of characters , If you need to enter more than one line in a TextBox control, you should change the Multiline property is to True.
Textbox passowrd character
Sometimes you want a textbox to receive password from the user. In order to keep the password confidential, you can set the PasswordChar property of a textbox to a specific character.
The above code set the PasswordChar to * , so when the user enter password then it display only * instead of typed characters.
How to Newline in TextBox
You can add new line in a textbox using two ways.
How to retrieve integer values from textbox ?
VB.Net String to Integer conversion
Parse method Converts the string representation of a number to its integer equivalent.
VB.Net String to Double conversion
How to allow only numbers in a textbox
Many of us have faced a situation where we want the user to enter a number in a TextBox. Click the following link that are going to make a Numeric Textbox which will accept only numeric values; if there are any values except numeric. More about.... How do I make a textbox that only accepts numbers
VB.Net Autocomplete TextBox
From the version Visual Studio 2005, some of the controls support Autocomplete feature including the TextBox controls. The properties like AutoCompleteCustomSource, AutoCompleteMode and AutoCompleteSource to perform a TextBox that automatically completes user input strings by comparing the prefix letters being entered to the prefixes of all strings in a data source. More about.... VB.Net Autocomplete TextBox
From the following VB.Net source code you can see some important property settings to a TextBox control.
- Visual Studio IDE
- How to Create a vb.net Windows Forms Application
- Label Control
- Button Control
- ComboBox Control
- ListBox Control
- Checked ListBox Control
- RadioButton Control
- CheckBox Control
- PictureBox Control
- ProgressBar Control
- ScrollBars Control
- DateTimePicker Control
- Treeview Control
- ListView Control
- Menu Control
- MDI Form
- Color Dialog Box
- Font Dialog Box
- OpenFile Dialog Box
- Print Dialog Box
- KeyPress event in VB.NET
- How to create Dynamic Controls in VB.NET ?
- How do i keep a form on top of others
- Timer Control - VB.Net