How to Change the Text Color of Labels in VB6.0

Save

Visual Basic labels help with navigation of your desktop applications. Visual Basic 6.0 is an older language used to create Windows software. Labels are placed adjacent to text boxes, drop-down boxes or other controls to tell the user what to enter for input. Labels are drawn with a black font by default. However, you can set the label's text color to match your application's color scheme.

  • Create the label variable. The label is created in code using the "Label" class. The following code shows you how to create a VB label:

    Dim lbl As Label

  • Assign some text to the label. Text is assigned to the label using the "Caption" property in VB6. This changes in VB.NET, which uses the "Text" property. The following code adds text to your label:

    lbl.Caption = "My label text."

  • Change the text color using the forecolor property. VB6 has color constants that make it easy to change the label's text color (see "Resources"). The following code changes the label's text to red:

    lbl.Forecolor = vbRed

References

  • Photo Credit text image by Ewe Degiampietro from Fotolia.com
Promoted By Zergnet

Comments

Resources

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!