Create a program that changes the color a specific control

Asked By 60 points N/A Posted on -
qa-featured

Hello!

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!

Thank you!

SHARE
Answered By 0 points N/A #178289

Create a program that changes the color a specific control

qa-featured

Hello Angela!

  

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

    End Sub

    Private Sub btngreen_Click(sender As System.Object, e As System.EventArgs) Handles btngreen.Click

        lbl1.BackColor = Color.Green

    End Sub

    Private Sub btnblue_Click(sender As System.Object, e As System.EventArgs) Handles btnblue.Click

        lbl1.BackColor = Color.Blue

    End Sub

End Class

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.

 

Related Questions