Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Button color to 0's and 1's filter_list
Author
Message
Button color to 0's and 1's #1
I', struggling with this small piece of code that gives 1 for green and 0 for red for each button in a group box. If I do this:

Code:
Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick
        For Each h As Button In outGB.Controls
            If TypeOf h Is Button Then
                If btnno >= 9 Then
                    btnno = 0
                Else
                    btnno += 1
                End If
                If  h.BackColor = Color.Green Then
                    result &= "1"
                ElseIf  h.BackColor = Color.Red Then
                    result &= "0"
                End If
            End If
        Next
        Label1.Text = result
        result = String.Empty
    End Sub
It does't work in order, it gives the data in random order. The solution (I think) is this:
Code:
Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick
        For Each h As Button In outGB.Controls
            If TypeOf h Is Button Then
                If btnno >= 9 Then
                    btnno = 0
                Else
                    btnno += 1
                End If
                If h.Name = "out" & btnno And h.BackColor = Color.Green Then
                    result &= "1"
                ElseIf h.Name = "out" & btnno And h.BackColor = Color.Red Then
                    result &= "0"
                End If
            End If
        Next
        Label1.Text = result
        result = String.Empty
    End Sub
BUT IT DOESN'T WORK !!! It gives to zeros that are flashing like crazy. There is no think that I haven't tried. This might be stupid, but very frustrating little pesky problem. Please help.

EDIT: You can see the above two snippets differ from only this
Code:
h.Name = "out" & btnno And
Please, anyone HELP !!! I need this very much.
[Image: mU9i19G.gif]

Reply







Users browsing this thread: 1 Guest(s)