📄 modulecom.bas
字号:
Attribute VB_Name = "Module1"
Public Echo As Boolean ' 回应串口 打开/关闭 标志。
Public X As Integer '输入
Public Y As Integer '输出
Public mark As Integer '用于对时间的设置的选择的标记
'以下四个变两是用来控制开关机时间的存储|| 以及做为时间的标志
Public time10 As Date
Public time11 As Date
Public time20 As Date
Public time21 As Date
Public a As Boolean
Public mmmm As Integer
Public Declare Function GetTickCount Lib "kernel32" () As Long
Dim CommPort As String, Handshaking As String, Settings As String
Public Sub Main()
On Error Resume Next
' 设置标题
App.Title = "投影机多串口控制程序" 'Visual Basic Terminal"
X = 0
Y = 0
' 载入注册设置
Settings = GetSetting(App.Title, "属性", "设置1", "") ' Frmcom.MSComm1.Settings]\
If Settings <> "" Then
Frmcom.MSComm1.Settings = Settings
If Err Then
MsgBox Error$, 48
Exit Sub
End If
End If
CommPort = GetSetting(App.Title, "属性", "通信端口1", "") ' Frmcom.MSComm1.CommPort
If CommPort <> "" Then Frmcom.MSComm1.CommPort = CommPort
Handshaking = GetSetting(App.Title, "属性", "握手1", "") 'frmTerminal.MSComm1.Handshaking
If Handshaking <> "" Then
Frmcom.MSComm1.Handshaking = Handshaking
If Err Then
MsgBox Error$, 48
Exit Sub
End If
End If
' Echo = GetSetting(App.Title, "属性", "回应", "") ' Echo
' On Error GoTo 0
If Err Then
MsgBox Error$, 48
Exit Sub
End If
'//////////////////////////////////////////////////////////////////////////////////////////
Settings = GetSetting(App.Title, "属性", "设置", "") ' Frmcom.MSComm1.Settings]\
If Settings <> "" Then
Frmcom.MSComm2.Settings = Settings
If Err Then
MsgBox Error$, 48
Exit Sub
End If
End If
CommPort = GetSetting(App.Title, "属性", "通信端口", "") ' Frmcom.MSComm1.CommPort
If CommPort <> "" Then Frmcom.MSComm2.CommPort = CommPort
Handshaking = GetSetting(App.Title, "属性", "握手", "") 'frmTerminal.MSComm1.Handshaking
If Handshaking <> "" Then
Frmcom.MSComm2.Handshaking = Handshaking
If Err Then
MsgBox Error$, 48
Exit Sub
End If
End If
' Echo = GetSetting(App.Title, "属性", "回应", "") ' Echo
' On Error GoTo 0
If Err Then
MsgBox Error$, 48
Exit Sub
End If
'//////////////////////////////////////////////////////////////////////////////////////////
time10 = GetSetting(App.Title, "属性", "开机时间1", "")
time11 = GetSetting(App.Title, "属性", "关机时间1", "")
time20 = GetSetting(App.Title, "属性", "开机时间2", "")
time21 = GetSetting(App.Title, "属性", "关机时间2", "")
If Err Then
MsgBox Error$, 48
' Exit Sub
End If
Frmcom.Show
End Sub
'//////////////////////////////////////////////////////////////////////////////////////////
Sub TimeDelay(DT As Long) '延时函数
Dim TT As Long
TT = GetTickCount()
Do
DoEvents
If GetTickCount - TT < 0 Then TT = GetTickCount
Loop Until GetTickCount - TT >= DT
End Sub
'Function WaitRS(Comm As MSComm, RS As String, DT As Long) As String
' Dim buf$, TT As Long
' buf = ""
' TT = GetTickCount
' Do
' buf = buf & Comm.Input
' Loop Until InStr(1, buf, RS) > 0 Or GetTickCount - TT >= DT
' If InStr(1, buf, RS) > 0 Then
' WaitRS = buf
' Else
' WaitRS = ""
' End If
'End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -