Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 50
Call Toggle(7)
Call Toggle(7)
End Sub
Private Sub Command1_Click(ByVal Index As Integer)
MsgBox(2 ^ Index)
Call Toggle(2 ^ Index)
End Sub
Private Sub Timer1_Timer()
Call Toggle(Rnd() * 8)
End Sub
Private Sub Toggle(ByVal Key As Integer)
If Key And 1 Then
If ToggleKey(VK_NUMLOCK) Then
Me.lblNumLock.BackColor =
System.Drawing.Color.Aquamarine
Else
Me.lblNumLock.BackColor =
System.Drawing.Color.RoyalBlue
End If
End If
If Key And 2 Then
If ToggleKey(VK_CAPITAL) Then
Me.lblCapsLock.BackColor =
System.Drawing.Color.Aquamarine
Else
Me.lblCapsLock.BackColor =
System.Drawing.Color.RoyalBlue
End If
End If
If Key And 4 Then
If ToggleKey(VK_SCROLL) Then
Me.lblScrollLock.BackColor =
System.Drawing.Color.Aquamarine
Else
Me.lblScrollLock.BackColor =
System.Drawing.Color.RoyalBlue
End If
End If
End Sub
Private Function ToggleKey(ByVal Key As Byte) As Boolean
Dim State As Boolean
Dim Keys(255) As Byte
Call GetKeyboardState(Keys(0))
State = Keys(Key)
If State <> True Then
Keys(Key) = 1
Else
Keys(Key) = 0
End If
Call SetKeyboardState(Keys(0))
ToggleKey = Not State
End Function
Private Sub Check1_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Check1.CheckedChanged
If Check1.Checked = True Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub btnNumLock_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnNumLock.Click
Call Command1_Click(0)
End Sub
Private Sub btnCaps_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnCaps.Click
Call Command1_Click(1)
End Sub
Private Sub btnScroll_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnScroll.Click
Call Command1_Click(2)
End Sub
Did Herfried's suggestion works for you?
If you have any concern on this issue, please post here.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.