toggle l button color in

toggle button color to green .
I woulls like to click the button, then its property  color turns green.
Then when it is green, I would like to populate textbox1 with "GO'
I click the button again it goes back to normal color then change the value to stop on textbox1
Who is Participating?
In VB6, first you must set the Style of the button to Graphical in the designer.  Then use this code:

Private Sub Command1_Click()
    If Command1.BackColor <> RGB(0, 255, 0) Then
        Command1.BackColor = RGB(0, 255, 0)
        Text1.Text = "Go"
        Command1.BackColor = vbButtonFace
        Text1.Text = "Stop"
    End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Button1.BackColor <> Color.LightGreen Then
            Button1.BackColor = Color.LightGreen
            TextBox1.Text = "Go"
            Button1.BackColor = System.Windows.Forms.Control.DefaultBackColor
            TextBox1.Text = "Stop"
        End If

    End Sub
zachvaldezAuthor Commented:
IN vb6  also?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.