How to Change Font Color in Visual Basic

Save

Developing a user-friendly and vibrant color application using Visual Basic, or VB, can be as easy as adding text to a control. In VB, the ForeColor property can be used to change the font color of almost any control that uses text. The font color of VB controls on a form use the system colors by default, but they can be changed dynamically. In programming, one way you can use the FontColor property is to change the color of text to communicate information to the user, such as a green for "Pass" and red for "Fail."

Things You'll Need

  • Microsoft Visual Basic Express
  • Launch Microsoft Visual Basic Express, click "New Project" on the left pane of your screen and then select "Windows Forms Application." Click "OK."

  • Double-click "TextBox" on the Toolbox pane to add the control to the form, and double-click "Button" to add a new button.

  • Double-click "Button1" to create the button click event procedure. Type the following code inside the procedure to change the font color of the text box control:

    Me.TextBox1.ForeColor = Color.ForestGreen

  • Press "F5" to run your program, then type a sentence in the text box control. Press "Button1" to change the font color to forest green.

References

  • Photo Credit Chad Baker/Photodisc/Getty Images
Promoted By Zergnet

Comments

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!