VB6 Tutorial 12: Label and TextBox Controls

Posted On 2018-04-01 by VB6Boy
Keywords:
Tags: VB6 Tutorials 
Views: 58

Title Uploaded Size
Password.zip 4/1/2018 10:31:57 AM 1,240
Text_Display_1.zip 4/1/2018 10:32:13 AM 1,110
Text_display_2.zip 4/1/2018 10:32:24 AM 1,140
ToolTip.zip 4/1/2018 10:32:36 AM 1,091


Looking for the more of the VB6 Tutorial? Here is the tutorial index.

Some basic properties of Label and TextBox control in Visual Basic 6 are explained in this lesson.

Properties of label

  • Appearance: Sets whether or not a label is painted with 3D effects.
  • BackStyle: Sets whether the background of the label is transparent or opaque.
  • Caption: Sets the text to be displayed.

Properties of TextBox

  • Enabled: Determines whether the TextBox can respond to user-generated events.
  • Locked: Determines whether the TextBox can be edited. You can prevent the user from changing the content of the TextBox.
  • MultiLine: Indicates whether it can accept multiple lines of text.
  • Alignment: Aligns the text to left justify, right justify or center.
  • MaxLength: Sets the maximum number of characters that can be entered. If you want to set a limit on the number of characters that the user can enter, you can do it very easily with the MaxLength property.
  • PasswordChar: This property is useful for a password program. For example, if u enter '*' as a value to this property, whatever character you type in, it will be shown as '*'.
  • ScrollBars: Says whether the TextBox has a scroll bar.
  • ToolTipText: Sets the text displayed when the mouse is paused over the control.

Example Programs

There are four example projects attached at the top of this post that demonstrate some of the available properties.

Note: The Password Program has used msgbox for output. To understand this program, you first need to learn about msgbox which is described in a later lesson.

Run-Time properties of TextBox

Run-time properties are not visible in the Properties Window. You need to write code to set run-time properties.

SelStart

Sets the position of the blinking cursor that appears in the TextBox Control. When the cursor is at the beginning of the text, the value of SelStart is 0. When its at the end of the text, it returns Len(text1.text). 'Len' is a string function that returns the length of the text or the number of characters in the text. Set SelStart property to move the cursor in the TextBox.

Example

Private Sub Form_Load()
    Text1.Text = "Visual" 
    Text1.SelStart = 3
End Sub

Output

event execution

SelLength

Sets the number of characters that has been selected or highlighted.

Example

Private Sub Form_Load()
    Text1.Text = "Visual" 
    Text1.SelLength = 3
End Sub

Output

event execution

SelText

Sets or returns the text that is currently selected or highlighted.

Example

Private Sub Form_Load()
    Text1.Text = "Visual"
    Text1.SelLength = 3
    Text1.Text = Text1.SelText
End Sub

Output

event execution

Looking for the more of the VB6 Tutorial? Here is the tutorial index.


About the Author

VB6Boy has posted a total of 71 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:23.20.165.182

Before you can post, you need to prove you are human. If you log in, this test goes away.




Code Links