TextBox in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes the TextBox control


TextBox

This control is a typical everyday text box. You can enter and modify text, click and drag to select text, press Ctrl+C to copy the selected text to the clipboard etc.

It is much simpler than the RichTextBox control described earlier in these tutorials.

It can use only one font, background color, and foreground color for all of its text.

It also cannot provide special formatting such as bullets, hanging indentation, and margins the way the RichTextBox control can.

Note: if you need those extra features, use a RichTextBox instead of a TextBox control.

Some of the most common TextBox properties are certainly MultiLine, MaxLength, ReadOnly and Text.

The MultiLine property determines whether the control displays multiple lines.

The MaxLength property determines the maximum number of characters the user can enter into the control.

The ReadOnly property determines whether the user can modify the control's text.

properties

The Text property simply gets or sets the text associated with the control.

    ' check if it's the initial text value
    If TextBox1.Text.Contains("your name here") Then
        TextBox1.BorderStyle = BorderStyle.FixedSingle
        TextBox1.ForeColor = Color.Red
        TextBox1.Text = "The name is required"
        Exit Sub
    End If

Previous Lesson | Next Lesson


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.