Visual Basic 2012 Coding Help please (1 Viewer)

douglas1013

New member
Local time
Today, 18:45
Joined
Nov 4, 2015
Messages
2
Visual Basic 2012 Coding Help
I am working on Visual Basic 2012 and need some help with the coding for the following programming exercise: Write a program to specify the foreground and background colors for a label containing the words VISUAL BASIC.

If the same color is selected from the two groups of radio buttons, the user should be informed immediately with a message box that the two colors must be different. Ex: You must choose two different colors from each group.

If no color has been selected from one or both of the group of radio buttons when the button is clicked, then the user should be told what information must be supplied through a message box to inform the user of the problems. Ex: You must choose a color from each group where the colors are not the same.

Here is what I have so far:
Public Class frmColors

Private Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
If radWhite.Checked Then
lblVisualBasic.ForeColor = Color.White
ElseIf radYellow.Checked Then
lblVisualBasic.ForeColor = Color.Yellow
ElseIf radRed.Checked Then
lblVisualBasic.ForeColor = Color.Red
ElseIf radBlue.Checked Then
lblVisualBasic.ForeColor = Color.Blue
End If

If radWhiteBG.Checked Then
lblVisualBasic.BackColor = Color.White
ElseIf radYellowBG.Checked Then
lblVisualBasic.BackColor = Color.Yellow
ElseIf radRedBG.Checked Then
lblVisualBasic.BackColor = Color.Red
ElseIf radBlueBG.Checked Then
lblVisualBasic.BackColor = Color.Blue
End If

If lblVisualBasic.ForeColor = lblVisualBasic.BackColor Then
MessageBox.Show("You must select a different color from each group")
End If

If radWhite.Checked = False OrElse radWhiteBG.Checked = False Then
MessageBox.Show("You must select a color from each group")
ElseIf radYellow.Checked = False OrElse radYellowBG.Checked = False Then
MessageBox.Show("You must select a color from each group")
ElseIf radRed.Checked = False OrElse radRedBG.Checked = False Then
MessageBox.Show("You must select a color from each group")
ElseIf radBlue.Checked = False OrElse radBlueBG.Checked = False Then
MessageBox.Show("You must select a color from each group")

End If

End Sub
End Class
 
Last edited:

Users who are viewing this thread

Top Bottom