⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fomcom.frm

📁 投影机双串口控制程序.rar是一个实力程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Exposed = False


Private Sub Command1_Click()
Command3_Click
Frmcomset1.Show
Frmcomset1.Caption = "投影机1的串口设置"
Me.Hide
End Sub

Private Sub Command10_Click()
On Error Resume Next
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11.Enabled = False
If Me.MSComm1.PortOpen = False Then
Me.MSComm1.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
MSComm1.Output = "00_r2" + vbCr
MSComm1.Output = "C06" + vbCr
TimeDelay 1000
MSComm1.Output = "00_r2" + vbCr
MSComm1.Output = "C06" + vbCr
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
End Sub

Private Sub Command11_Click()
On Error Resume Next
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11.Enabled = False
If Me.MSComm1.PortOpen = False Then
Me.MSComm1.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
MSComm1.Output = "00_v1" + vbCr
MSComm1.Output = "C07" + vbCr
TimeDelay 1000
MSComm1.Output = "00_v1" + vbCr
MSComm1.Output = "C07" + vbCr
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
End Sub
'///////////////////////////////////////////////////////////////////////
Private Sub Command12_Click()
On Error Resume Next
Command16.Enabled = False
Command15.Enabled = False
Command14.Enabled = False
Command13.Enabled = False
Command12.Enabled = False
If Me.MSComm2.PortOpen = False Then
Me.MSComm2.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
'MSComm2.Output = "00_v1" + vbCr
MSComm2.Output = "C07" + vbCr
TimeDelay 1000
MSComm2.Output = "C07" + vbCr
Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True

End Sub

Private Sub Command13_Click()
On Error Resume Next
Command16.Enabled = False
Command15.Enabled = False
Command14.Enabled = False
Command13.Enabled = False
Command12.Enabled = False
If Me.MSComm2.PortOpen = False Then
Me.MSComm2.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If

'MSComm2.Output = "00_r2" + vbCr
MSComm2.Output = "C06" + vbCr
TimeDelay 1000
MSComm2.Output = "C06" + vbCr

Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True

End Sub

Private Sub Command14_Click()
On Error Resume Next
Command16.Enabled = False
Command15.Enabled = False
Command14.Enabled = False
Command13.Enabled = False
Command12.Enabled = False
If Me.MSComm2.PortOpen = False Then
Me.MSComm2.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
'MSComm2.Output = "00_r1" + vbCr
MSComm2.Output = "C05" + vbCr
TimeDelay 1000
MSComm2.Output = "C05" + vbCr

Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True
End Sub

Private Sub Command15_Click()
Dim aa As String
Command16.Enabled = False
Command15.Enabled = False
Command14.Enabled = False
Command13.Enabled = False
Command12.Enabled = False
On Error Resume Next
aa = Text1.Text
If Me.MSComm2.PortOpen = False Then
    Me.MSComm2.PortOpen = True
    If Err Then
        MsgBox Error$, 48
        Exit Sub
    End If
End If
'MSComm2.Output = aa & vbCr
MSComm2.Output = "C02" + vbCr
TimeDelay 2000
MSComm2.Output = "C02" + vbCr
TimeDelay 2000
MSComm2.Output = "C02" + vbCr

Option1(1).Value = True

Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True
End Sub

Private Sub Command16_Click()
On Error Resume Next
Command16.Enabled = False
Command15.Enabled = False
Command14.Enabled = False
Command13.Enabled = False
Command12.Enabled = False
If Me.MSComm2.PortOpen = False Then
Me.MSComm2.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
'MSComm2.Output = "00!" + vbCr
MSComm2.Output = "C00" + vbCr
TimeDelay 2000
MSComm2.Output = "C00" + vbCr
TimeDelay 2000
MSComm2.Output = "C00" + vbCr
Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True

End Sub



Private Sub Command2_Click()
Command4_Click

Frmcomset2.Show
Frmcomset2.Caption = "投影机2的串口设置"
Me.Hide
End Sub

Private Sub Command3_Click()
On Error Resume Next

MSComm1.PortOpen = Not MSComm1.PortOpen
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
If MSComm1.PortOpen = True Then
Command3.Caption = "断开串口"
Label7.Caption = "串口com" & MSComm1.CommPort & "通信中"

ElseIf MSComm1.PortOpen = False Then
Command3.Caption = "连接串口"
Label7.Caption = ""
End If

Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True

End Sub

Private Sub Command4_Click()
On Error Resume Next
Command16.Enabled = True
Command15.Enabled = True
Command14.Enabled = True
Command13.Enabled = True
Command12.Enabled = True

MSComm2.PortOpen = Not MSComm2.PortOpen
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
If MSComm2.PortOpen = True Then
Command4.Caption = "断开串口"
Label8.Caption = "串口com" & MSComm2.CommPort & "通信中"

ElseIf MSComm2.PortOpen = False Then
Command4.Caption = "连接串口"
Label8.Caption = ""
End If

End Sub

Private Sub Command5_Click()

Command3_Click

Frmtime.Show
Option2(1).Value = True

Me.Hide
End Sub

Private Sub Command6_Click()
Command4_Click
Frmtime1.Show
Option1(1).Value = True

Me.Hide
End Sub

Private Sub Command7_Click()
On Error Resume Next
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11.Enabled = False
If Me.MSComm1.PortOpen = False Then
Me.MSComm1.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
MSComm1.Output = "00!" + vbCr
MSComm1.Output = "C00" + vbCr
TimeDelay 2000
MSComm1.Output = "00!" + vbCr
MSComm1.Output = "C00" + vbCr
TimeDelay 2000
MSComm1.Output = "00!" + vbCr
MSComm1.Output = "C00" + vbCr

Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
End Sub

Private Sub Command8_Click()
Dim aa As String

On Error Resume Next
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11.Enabled = False
aa = Text1.Text
If Me.MSComm1.PortOpen = False Then
Me.MSComm1.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
MSComm1.Output = aa & vbCr
MSComm1.Output = "C02" + vbCr
TimeDelay 2000
MSComm1.Output = aa & vbCr
MSComm1.Output = "C02" + vbCr
TimeDelay 2000
MSComm1.Output = aa & vbCr
MSComm1.Output = "C02" + vbCr

Option2(1).Value = True

Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True

End Sub

Private Sub Command9_Click()
On Error Resume Next
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command10.Enabled = False
Command11.Enabled = False
If Me.MSComm1.PortOpen = False Then
Me.MSComm1.PortOpen = True
If Err Then
    MsgBox Error$, 48
    Exit Sub
End If
End If
MSComm1.Output = "00_r1" + vbCr
MSComm1.Output = "C05" + vbCr
TimeDelay 1000
MSComm1.Output = "00_r1" + vbCr
MSComm1.Output = "C05" + vbCr

Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command10.Enabled = True
Command11.Enabled = True
End Sub

Private Sub Form_Load()
Label2.Caption = ""
Label4.Caption = ""
Label5.Caption = Time
Label7.Caption = ""
Label8.Caption = ""
Label9.Caption = ""
Label10.Caption = ""
Label11.Caption = ""
Label12.Caption = ""



If MSComm1.PortOpen = True Then
   Label2.Caption = "串口连接中"
ElseIf MSComm1.PortOpen = False Then
   Label2.Caption = "串口断开中"
End If


If MSComm2.PortOpen = True Then
    Label4.Caption = "串口连接中"
ElseIf MSComm2.PortOpen = False Then
    Label4.Caption = "串口断开中"
End If

Option2(1).Value = True

Option1(1).Value = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
End

End Sub

Private Sub mnuabout_Click()
frmAbout.Show
Me.Hide
End Sub

Private Sub mnuanswer_Click()
Frmhelp.Show
Me.Hide
End Sub




Private Sub mnuexit_Click()
End
End Sub

Private Sub Timer1_Timer()
    Label5.Caption = Time
    
    If MSComm1.PortOpen = True Then
       Label2.Caption = "串口连接中"
       Label7.Caption = "串口com" & MSComm1.CommPort & "通信中"
      Command3.Caption = "断开串口"
      
    ElseIf MSComm1.PortOpen = False Then
       Label2.Caption = "串口断开中"
       Label7.Caption = ""
      Command3.Caption = "连接串口"

    End If
    
    
    If MSComm2.PortOpen = True Then
        Label4.Caption = "串口连接中"
        Label8.Caption = "串口com" & MSComm2.CommPort & "通信中"
      Command4.Caption = "断开串口"

    ElseIf MSComm2.PortOpen = False Then
        Label4.Caption = "串口断开中"
        Label8.Caption = ""
      Command4.Caption = "连接串口"

    End If
    
    
    
End Sub

Private Sub Timer2_Timer()
Dim ttt As Date
Dim tt10 As Date
Dim tt11 As Date
Dim tt20 As Date
Dim tt21 As Date


Label9.Caption = time10
Label12.Caption = time11
Label10.Caption = time20
Label11.Caption = time21
ttt = Time
tt10 = time10
tt11 = time11
tt20 = time20
tt21 = time21

    
    If Option2(0).Value = True Then 'mscomm1的时间开启控制
        
        If tt10 = ttt Then
             Command7_Click
        End If
        
        If tt11 = ttt Then
             Command8_Click
        End If
        
    End If

    If Option1(0).Value = True Then 'mscomm2的时间开启控制
       
        If tt20 < ttt And tt21 > ttt Then
           Command16_Click
        End If
        
        If tt21 = ttt Then
           Command15_Click
        End If
        
    End If


End Sub
'Private Sub Timer1_Timer()
'Label1.Caption = Time
'If t1 = Label1.Caption Then '用来控制时间
''MsgBox "打开设备", , "提示"
'
'cmdopen_Click
'ElseIf t2 = Label1.Caption Then
''MsgBox "关闭设备", , "提示"
' ti = ""
' t2 = ""
' comtime.Caption = "打开定时开关"
'cmdclose_Click
'End If
'
'End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -