# 電腦硬體裝修乙級Visual Basic
## 第二版 新版
```vb
Dim a,b(99),c As Integer
Private Sub Command1_Click(Index As Integer)
a=Index
c=0
End Sub
Private Sub display(no)
For i=0 To 7
If no Mod 2=1 And a=1 Then G(i).FillColor=RGB(0,255,0)
If no Mod 2=1 And a=2 Then R(i).FillColor=RGB(255,0,0)
no=no\2
Next i
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen Then
MSComm1.Output ="R0"
MSComm1.Output ="G0"
MSComm1.PortOprn=False
Command2_Caption="Connect Bluetooth"
Else
MSComm1.PortOpen =True
Command2.Caption="Disconnect Bluetooth"
MSComm1.Output ="R0"
MSComm1.Output ="G0"
End If
End Sub
Private Sub Timer1_Timer()
b(0) = &H18
b(1) = &H24
b(2) = &H42
b(3) = &H81
Label1.Caption="Current Time:" & Time$
For i=0 To 7
G(i).FillColor=vbWhite
R(i).FillColor=vbWhite
Next i
If MSComm1.PortOpen Then
For i=0 To 7
G(i).FillColor=RGB(0,128,0)
R(i).FillColor=RGB(128,0,0)
Next i
If a=1 Then MSComm1.Output ="G" & b(c):display(b(c))
If a=2 And c<=8 Then MSComm1.Output="R" & 2^c:display(2^c)
End If
If a=3 Then MSComm1.Output = "R0": MSCOmm1.Output = "G0":End
If c>15 Then c=15 Else c=c+1
End Sub
```
## 第一版
```vb
Dim a,b(99),c As Integer
Private Sub Command1_Click(Index As Integer)
a=Index
c=0
End Sub
Private Sub display(no)
For i=0 To 7
If no Mod 2=1 And a=1 Then G(i).FillColor=RGB(0,255,0)
If no Mod 2=1 And a=2 Then R(i).FillColor=RGB(255,0,0)
no=no\2
Next i
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen Then
MSComm1.Output="R0"
MSComm1.Output="G0"
MSComm1.PorOpen=False
Command2.Caption="Connect Bluetooth"
Else
MSComm1.PortOpen=True
Command2.Caption="Disconnect Bluetooth"
MSComm1.Output="R0"
MSComm1.Output="G0"
End If
End Sub
Private Sub Timer1_Time()
b(0)=&H18
b(1)=&H24
b(2)=&H42
b(3)=&H81
Label1.Caption="Current Time:" & Time$
For i=0 To 7
G(i).FillColor=vbwhite
R(i).FillColor=vbwhite
Next i
If MSComm1.PortOpen Then
For i=0 To 7
G(i).FillColor=RGB(0,128,0)
R(i).FillColor=RGB(128,0,0)
Next i
If a=1 Then MSComm1,Output="G" & b(c):display(b(c))
If a=2 And C<=8 Then MSComm1.Output="R" & 2^c:display(2^C)
End If
If a=3 Then End
If C>15 Then c=15 Else c=c+1
End Sub
███████╗███████╗ █████╗ ██╗ ██╗
██╔════╝██╔════╝██╔══██╗╚██╗ ██╔╝
█████╗ ███████╗███████║ ╚████╔╝
██╔══╝ ╚════██║██╔══██║ ╚██╔╝
███████╗███████║██║ ██║ ██║
╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝
```