N/APosted on - 04/10/2015
I want to create a program in Visual Basic 2015. I want to create a program that will change the color of label while pushing some controls. What are the controls that I need to use that must be included in the form? What is the equivalent values of R-G-B? I want to add more features, If am going to click the “x” or close button, I want to post message about me or anything to make it more interactive to user. Can I use message box like option in this part?
Please help me!
Create a program that changes the color a specific control
Here is the sample output and program codes and explanation below. You need a Form, 1 Label control, and 3 Command Buttons. Change the properties as illustrated below.
1. Label >> text property changed to “by: JOHN HART” or replace it with you name.
2. Label 1 >> change name property to lbl1
3. Command buttons >> change the text properties for each to corresponding colors.
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles btnRed.Click
lbl1.BackColor = Color.Red
Private Sub btngreen_Click(sender As System.Object, e As System.EventArgs) Handles btngreen.Click
lbl1.BackColor = Color.Green
Private Sub btnblue_Click(sender As System.Object, e As System.EventArgs) Handles btnblue.Click
lbl1.BackColor = Color.Blue
It is simple for any beginners to understand the codes.
The line that says “lbl1.BackColor = Color.Red” calls for the VB functions to update or change the color of the label back color to red and respectively.