|
各位大大好~~小弟最近在寫vb控制端程式
以下是小弟寫的程式:
Private Sub Form_Load()
On Error Resume Next
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm1.PortOpen = True
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
MSComm1.CommPort = 1
MSComm.Settings = "1200,n,8,1"
MSComm1.PortOpen = True
Text1.Text = "已選用com1"
Else
MSComm1.PortOpen = False
MSComm1.CommPort = 2
MSComm1.PortOpen = True
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
MSComm1.CommPort = 2
MSComm1.Settings = "1200,n,8,1"
MSComm1.PortOpen = True
Text1.Text = "已選用com2"
Else
MSComm1.PortOpen = False
Text1.Text = "通訊連接阜無法使用"
End If
End If
End Sub
Private Sub off_Click()
Text1.Text = "連線中"
MSComm1.Output = "0"
delayms 100
buf = MSComm1.Input
If buf = "2" Then
單手舉起.FillColor = pwm(150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150)
Else
Text1.Text = "連結失敗"
End If
End Sub
Private Sub 單手舉起_Click()
Text1.Text = "連結中"
MSComm1.Output = "1"
delayms 100
buf = MSComm1.Input
If buf = "1" Then
單手舉起.FillColor = pwm(150, 230, 150, 150, 150, 150, 150, 190, 150, 150, 150, 150, 150, 150, 150, 150)
Else
Text1.Text = "無法動作"
End If
End Sub
Private Sub 結束_Click()
On Error Resume Next
msg = "你確定要結束嗎??"
cod = 65
Title = "關閉控制端"
return_value = MsgBox(msg, code, Title)
If return_value = 1 Then
off_Click
MSComm1.PortOpen = False
End
End If
End Sub
小弟只寫了一個動作模式.在模擬的時候他說我的單手舉起那一段程式有錯誤
請問各位大大,這ㄍ程式是少了什麼還是有寫錯呢
ps:小弟是使用pc控制89c52 |
|