TextBox Control in VB.Net
TextBox in the .Net applications are like the input box both have the input fields to insert data. The TextBox can either input the single line text or the multi-line texts. TextBox control allows entering text at the runtime of the programs.
Add TextBox control to the Form
From the toolbox drag & drop the text box control to the form.
Accept Values From TextBox
You may accept the values from TextBox as shown below.
Dim a As String = TextBox1.Text
TextBox Control Properties
The following table shows the popular using TextBox control properties.
Properties |
Description |
TextAlign | Text alignment is set using this property |
Multiline | This property is used to set more than one line text |
ScrollBars | This property is used to specify vertical and horizontal scroll bars. |
MaxLength | Property used to specify the maximum number of characters accepted by a TextBox Control. |
Enabled | Property used to enable a textbox control. |
Index | Property used to specify the index of a control array. |
Readonly | Property is set to true to use the control, false the control cannot be used. |
SelectionLength | Property is used set or get the number of characters selected in the text box. |
SelectionStart | Property is used set or get the starting point of a text box. |
SelectedText | Property is used for indicating the currently selected text box. |
TextBox Control Methods
The following table shows the most used TextBox Control methods.
Method |
Descrtiption |
AppendText | Appends text to the current text of a text box. |
Clear | Clears all text from the text box control. |
Copy | Copies the current selection in the text box to the Clipboard. |
Cut | Moves the current selection in the text box to the Clipboard. |
Paste | Replaces the current selection in the text box with the contents of the Clipboard. |
Paste(String) | Sets the selected text to the specified text without clearing the undo buffer. |
ResetText | Resets the Text property to its default value. |
ToString | Returns a string that represents the TextBoxBase control. |
Undo | Undoes the last edit operation in the text box. |
TextBox Control Events
The following table shows the common events of TextBox control.
Event |
Desription |
Click | Occurs when the control is clicked. |
DoubleClick | Occurs when the control is double-clicked. |
TextAlignChanged | Occurs when the TextAlign property value changes. |