• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

toggle l button color in vb.net

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
0
zachvaldez
Asked:
zachvaldez
  • 2
2 Solutions
 
PaulHewsCommented:
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"
        Else
            Button1.BackColor = System.Windows.Forms.Control.DefaultBackColor
            TextBox1.Text = "Stop"
        End If

    End Sub
0
 
zachvaldezAuthor Commented:
IN vb6  also?
0
 
PaulHewsCommented:
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"
    Else
        Command1.BackColor = vbButtonFace
        Text1.Text = "Stop"
    End If
   
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now