Option Explicit
Pubilc Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
pubilc Declare Sub PortOut Lib "io.dll" (ByVal Port As Integer, ByVal Value As Byte)
Pubilc Declare Function Portin lib "io.dll" (ByVal Port As Integer) As Byte
Option Explicit
Dim bin As Variant
Dim StopFlag As Boolean
Private Sub cmdAllOff_Click()
PortOut &H378, &H0
End Sub
Private Sub cmdAllOn_Click()
PortOut &H378, &HFF
End Sub
Private Sub cmdD0_Click()
PortOut &H378, &H1
End Sub
Private Sub cmdD1_Click()
PortOut &H378, &H2
End Sub
Private Sub cmdD2_Click()
PortOut &H378, &H4
End Sub
Private Sub cmdD3_Click()
PortOut &H378, &H8
End Sub
Private Sub cmdD4_Click()
PortOut &H378, &H10
End Sub
Private Sub cmdD5_Click()
PortOut &H378, &H20
End Sub
Private Sub cmdD6_Click()
PortOut &H378, &H40
End Sub
Private Sub cmdD7_Click()
PortOut &H378, &H80
End Sub
Private Sub cmdFlash_Click()
Dim N As Integer
StopFlag = False
For N = 0 To 255
PortOut &H378, N
txtFlash = Hex(N)
Sleep 100 ' milliseconds
DoEvents 'Allows text box to be updated
If StopFlag = True Then
Exit Sub
End If
Next N
End Sub
Private Sub cmdStopFlash_Click()
StopFlag = True
End Sub
Private Sub Form_Load()
StopFlag = False
PortOut &H378, &H0
End Sub
Private Sub Timer1_Timer()
Dim Status As Integer
Dim Data As Integer
Data = PortIn(&H378)
Status = PortIn(&H379)
If Status = &H7F Then
Image1.Picture = LoadPicture(App.Path & "/flote1.jpg")
Else
Image1.Picture = LoadPicture(App.Path & "/toGround1.jpg")
End If
'DATA
If Data And &H1 Then
ShapLED0.BackColor = vbGreen
Else
ShapLED0.BackColor = vbWhite
End If
If Data And &H2 Then
ShapLED1.BackColor = vbGreen
Else
ShapLED1.BackColor = vbWhite
End If
If Data And &H4 Then
ShapLED2.BackColor = vbGreen
Else
ShapLED2.BackColor = vbWhite
End If
If Data And &H8 Then
ShapLED3.BackColor = vbGreen
Else
ShapLED3.BackColor = vbWhite
End If
If Data And &H10 Then
ShapLED4.BackColor = vbGreen
Else
ShapLED4.BackColor = vbWhite
End If
If Data And &H20 Then
ShapLED5.BackColor = vbGreen
Else
ShapLED5.BackColor = vbWhite
End If
If Data And &H40 Then
ShapLED6.BackColor = vbGreen
Else
ShapLED6.BackColor = vbWhite
End If
If Data And &H80 Then
ShapLED7.BackColor = vbGreen
Else
ShapLED7.BackColor = vbWhite
End If
'STATUS
If Status And &H8 Then
CheckStatus3 = 1
Else
CheckStatus3 = 0
End If
If Status And &H10 Then
CheckStatus4 = 1
Else
CheckStatus4 = 0
End If
If Status And &H20 Then
CheckStatus5 = 1
Else
CheckStatus5 = 0
End If
If Status And &H40 Then
CheckStatus6 = 1
Else
CheckStatus6 = 0
End If
If Status And &H80 Then
CheckStatus7 = 1
Else
CheckStatus7 = 0
End If
End Sub
Option Explicit
Pubilc Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
pubilc Declare Sub PortOut Lib "io.dll" (ByVal Port As Integer, ByVal Value As Byte)
Pubilc Declare Function Portin lib "io.dll" (ByVal Port As Integer) As Byte
อะนเดียวกับด้านบนนะค่ะ