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.
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
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
When enter the value in TextBox then TextChanged event will fire and entered value will show in Label.
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
Text is written in Multiline.
Leave Comment