Need some help on a program again (1 Viewer)

jmonahan2009

New member
Local time
Yesterday, 18:23
Joined
Oct 6, 2011
Messages
6
I need some help on a program again. Don't remember if I explained this in my last post, but I'm taking a VB class in school, and the professor is absolutely horrible at teaching it. I've got a pretty good handle on this stuff and I'm usually able to figure it out on my own, but now is not one of those times.

The assignment says:
"Write a program to specify the foreground and background colors for a label containing the words "VISUAL BASIC". If the same color is checked from the two group boxes, the user should be informed immediately that the two colors must be different. If no color has been selected from one or both of the group boxes when the button is clicked, then the user should be told what information must be supplied."

I've been able to get it to change the colors of the label without a problem, but I can't get it to interject with a message box if the same color is selected in both groupings. Here's my code:

Code:
Public Class Form1
    Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click

        If fgWhite.Checked Then
            Label1.ForeColor = Color.White
        ElseIf fgYellow.Checked Then
            Label1.ForeColor = Color.Yellow
        ElseIf fgRed.Checked Then
            Label1.ForeColor = Color.Red
        ElseIf fgBlue.Checked Then
            Label1.ForeColor = Color.Blue

        End If

        If bgWhite.Checked Then
            Label1.BackColor = Color.White
        ElseIf bgYellow.Checked Then
            Label1.BackColor = Color.Yellow
        ElseIf bgRed.Checked Then
            Label1.BackColor = Color.Red
        ElseIf bgBlue.Checked Then
            Label1.BackColor = Color.Blue

        End If

    End Sub

End Class
I tried using an If Else statement that basically said "if fgBlue.checked & bgBlue.checked then MessageBox.Show("You must select two different colors.") but it gave me some sort of boolean error.

EDIT: Okay, I got it to notify the user that he/she must select two different colors if they select the same color in both groupings. But I don't know how to do the second part. The "If no color has been selected from one or both of the group boxes when the button is clicked, then the user should be told what information must be supplied." part.
 
Last edited:

rajsingla

New member
Local time
Yesterday, 18:23
Joined
Oct 8, 2011
Messages
1
Public Class Form1
Private Sub btnApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnApply.Click

If fgWhite.Checked Then
Label1.ForeColor = Color.White
ElseIf fgYellow.Checked Then
Label1.ForeColor = Color.Yellow
ElseIf fgRed.Checked Then
Label1.ForeColor = Color.Red
ElseIf fgBlue.Checked Then
Label1.ForeColor = Color.Blue

End If



If bgWhite.Checked Then
Label1.BackColor = Color.White
ElseIf bgYellow.Checked Then
Label1.BackColor = Color.Yellow
ElseIf bgRed.Checked Then
Label1.BackColor = Color.Red
ElseIf bgBlue.Checked Then
Label1.BackColor = Color.Blue

End If

End Sub

End Class

i think this prog. is right
 

Users who are viewing this thread

Top Bottom