经典的串口调试助手源代码(一)
2011年05月26日
Dim OutputAscii As Boolean
Dim InputString As String
Dim OutputString As String'=====================================================================================
' 变量定义
'=====================================================================================
Option Explicit ' 强制显式声明
Dim ComSwitch As Boolean ' 串口开关状态判断
Dim FileData As String ' 要发送的文件暂存
Dim SendCount As Long ' 发送数据字节计数器
Dim ReceiveCount As Long ' 接收数据字节计数器
Dim InputSignal As String ' 接收缓冲暂存
Dim OutputSignal As String ' 发送数据暂存
Dim DisplaySwitch As Boolean ' 显示开关
Dim ModeSend As Boolean ' 发送方式判断
Dim Savetime As Single ' 时间数据暂存 延时用
Dim SaveTextPath As String ' 保存文本路径
' 网页超链接申明
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub CloseCom() '关闭串口
On Error GoTo Err
If MSComm.PortOpen = True Then MSComm.PortOpen = False ' 先判断串口是否打开,如果打开则先关闭
txtstatus.Text = "STATUS:COM Port Cloced" ' 串口状态显示
mnuconnect.Caption = "断开串口"
cmdswitch.Caption = "打开串口"
'ImgSwitch.Picture = LoadPicture("f:\我的VB\串口调试软件\图片\guan.jpg") ' 显示串口已经关闭的图标
ImgSwitchoff.Visible = True
ImgSwitchon.Visible = False
Err:
End Sub
Private Sub UpdateStatus()
If MSComm.PortOpen Then
StatusBar1.Panels(1).Text = "Connected"
mnuautosend.Caption = "自动发送"
mnuconnect.Caption = "断开串口"
Else
StatusBar1.Panels(1).Text = "断开串口"
mnuautosend.Caption = "disautosend"
mnuconnect.Caption = "打开串口"
End If
StatusBar1.Panels(2).Text = "COM" & MSComm.CommPort
StatusBar1.Panels(3).Text = MSComm.Settings
If (OutputAscii) Then
StatusBar1.Panels(4) = "ASCII"
Else
StatusBar1.Panels(4) = "HEX"
End If
'
On Error GoTo Err
2011年05月26日
Dim OutputAscii As Boolean
Dim InputString As String
Dim OutputString As String'=====================================================================================
' 变量定义
'=====================================================================================
Option Explicit ' 强制显式声明
Dim ComSwitch As Boolean ' 串口开关状态判断
Dim FileData As String ' 要发送的文件暂存
Dim SendCount As Long ' 发送数据字节计数器
Dim ReceiveCount As Long ' 接收数据字节计数器
Dim InputSignal As String ' 接收缓冲暂存
Dim OutputSignal As String ' 发送数据暂存
Dim DisplaySwitch As Boolean ' 显示开关
Dim ModeSend As Boolean ' 发送方式判断
Dim Savetime As Single ' 时间数据暂存 延时用
Dim SaveTextPath As String ' 保存文本路径
' 网页超链接申明
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub CloseCom() '关闭串口
On Error GoTo Err
If MSComm.PortOpen = True Then MSComm.PortOpen = False ' 先判断串口是否打开,如果打开则先关闭
txtstatus.Text = "STATUS:COM Port Cloced" ' 串口状态显示
mnuconnect.Caption = "断开串口"
cmdswitch.Caption = "打开串口"
'ImgSwitch.Picture = LoadPicture("f:\我的VB\串口调试软件\图片\guan.jpg") ' 显示串口已经关闭的图标
ImgSwitchoff.Visible = True
ImgSwitchon.Visible = False
Err:
End Sub
Private Sub UpdateStatus()
If MSComm.PortOpen Then
StatusBar1.Panels(1).Text = "Connected"
mnuautosend.Caption = "自动发送"
mnuconnect.Caption = "断开串口"
Else
StatusBar1.Panels(1).Text = "断开串口"
mnuautosend.Caption = "disautosend"
mnuconnect.Caption = "打开串口"
End If
StatusBar1.Panels(2).Text = "COM" & MSComm.CommPort
StatusBar1.Panels(3).Text = MSComm.Settings
If (OutputAscii) Then
StatusBar1.Panels(4) = "ASCII"
Else
StatusBar1.Panels(4) = "HEX"
End If
'
On Error GoTo Err