04-07-2008 08:13 AM
SwitchState = SwitchArray1.GetValues
LedArray1.SetValues(SwitchState)
'textbox1.Text= WHAT CODE DO I USE TO SHOW WHICH SWITCH WAS CHANGED?? End Sub04-07-2008 01:13 PM - edited 04-07-2008 01:13 PM
Hi lburberry,
You just need to compare the previous set of Boolean values to the most recent set that is returned by GetValues in your ValuesChanged event.
Dim oldValues() As Boolean = Nothing
Dim firstTime As Boolean = False
Private Sub ValuesChanged(......
If (firstTime) Then
Dim newValues() As Boolean = Nothing
newValues = SwitchArray1.GetValues()
Dim changedValue As String = String.Empty
For index As Integer = 0 To oldValues.Length - 1
If (oldValues(index) <> newValues(index)) Then
changedValue = (index + 1).ToString() ' Adding one in case you don't won't the index offset
Exit For
End If
Next
TextBox1.Text = changedValue
End If
End Sub
' I decided to set the oldValues to the default state when the Form Load event occurs; You can do whatever you want
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oldValues = SwitchArray1.GetValues()
firstTime = True
End Sub
Hope this helps!
Best Regards,
04-07-2008 01:19 PM
04-09-2008 09:16 AM - edited 04-09-2008 09:17 AM
04-09-2008 09:27 AM
Thank you. It works!
That is the syntax I was looking for.
Lee