Home > DeveloperSection > Articles > TextBox Control in VB.Net

TextBox Control in VB.Net


VB.Net VB.Net 
Ratings:
0 Comment(s)
 7835  View(s)
Rate this:

TextBox Control in VB.Net

The TextBox control accepts input from the user. It can also be used to display text. By default we can enter up to 2048 characters in a TextBox but if the Multiline property is set to True we can enter up to 32KB of text.

How to use TextBox control

Drag and drop TextBox control from toolbox on the windowForm.

TextBox Control in VB.Net

Add text In TextBox

Code:

 

 Private Sub Form17_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       'Hello text will show in textbox

        TextBox1.Text = "Hello"

 End Sub

TextBox Control in VB.Net

TextChanged Event of TextBox

Code:

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        'entered value will show in Label2

        Label2.Text = "Price is " + TextBox1.Text + " Rs."

 End Sub

TextBox Control in VB.Net

When enter the value in TextBox then TextChanged event will fire and entered value will show in Label.

TextBox Control in VB.Net

 Textbox Properties

ReadOnly: Makes this TextBox readonly. It doesn't allow to enter any text.

Scrollbars: Allows to add a scrollbar to a Textbox. Very useful when the TextBox is multiline.

Multiline:   Setting this property to True makes the TextBox multiline which allows to accept multiple lines of text. Default value is False.

Private Sub Form17_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load     

        'makes TextBox MultiLine

        TextBox1.Multiline = True

End Sub

TextBox Control in VB.Net

Text is written in Multiline.

           


Don't want to miss updates? Please click the below button!

Follow MindStick