📄
字号:
Height = 440
Left = 720
TabIndex = 1
Top = 1740
Width = 870
End
Begin VB.Image ImgSwitchOn
Appearance = 0 'Flat
Height = 420
Left = 120
Picture = "串口调试助手.frx":7C58
Top = 1680
Width = 450
End
Begin VB.Image ImgSwitchOff
Height = 420
Left = 120
Picture = "串口调试助手.frx":B6F5
Top = 1680
Width = 450
End
Begin VB.Label Label8
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "停止位"
Height = 255
Left = 50
TabIndex = 33
Top = 1400
Width = 600
End
Begin VB.Label Label7
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "数据位"
Height = 255
Left = 50
TabIndex = 32
Top = 1080
Width = 600
End
Begin VB.Label Label6
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "校验位"
Height = 255
Left = 50
TabIndex = 31
Top = 760
Width = 600
End
Begin VB.Label Label5
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "波特率"
Height = 255
Left = 50
TabIndex = 30
Top = 470
Width = 600
End
Begin VB.Label Label4
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "串口"
Height = 255
Left = 50
TabIndex = 29
Top = 160
Width = 600
End
End
Begin VB.TextBox TxtReceive
Height = 4750
Left = 1800
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
Top = 6
Width = 8990
End
Begin VB.Label LblWeb
BackColor = &H0091CACA&
Caption = "WEB"
ForeColor = &H008A7839&
Height = 220
Left = 8880
MouseIcon = "串口调试助手.frx":EE3B
TabIndex = 46
Top = 5760
Width = 300
End
Begin VB.Label LblNewDate
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "显示日前"
Height = 255
Left = 240
TabIndex = 45
Top = 4440
Width = 1215
End
Begin VB.Label LblNowTime
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "当前时间"
ForeColor = &H00000000&
Height = 195
Left = 240
TabIndex = 44
Top = 4200
Width = 1215
End
Begin VB.Label Label14
BackColor = &H0091CACA&
Caption = "毫秒"
Height = 255
Left = 2000
TabIndex = 42
Top = 5760
Width = 450
End
Begin VB.Label LblArtoSendCyc
BackColor = &H0091CACA&
Caption = "自动发送周期:"
Height = 200
Left = 60
TabIndex = 40
Top = 5760
Width = 1270
End
Begin VB.Label LblAutoSend
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "自动发送(周期改变后重选)"
Height = 200
Left = 240
TabIndex = 39
Top = 5510
Width = 2215
End
Begin VB.Label Label11
Alignment = 2 'Center
BackColor = &H0091CACA&
Caption = "十六进制发送"
Height = 200
Left = 240
TabIndex = 38
Top = 5200
Width = 1200
End
Begin VB.Label Label10
BackColor = &H0091CACA&
Caption = "十六进制显示"
Height = 200
Left = 330
TabIndex = 35
Top = 3140
Width = 1200
End
Begin VB.Label LblArtoclear
BackColor = &H0091CACA&
Caption = "自动清空"
Height = 200
Left = 330
TabIndex = 34
Top = 2870
Width = 800
End
Begin VB.Label LblSend
BackColor = &H0091CACA&
BorderStyle = 1 'Fixed Single
Caption = "发送的字符/数据"
Height = 270
Left = 1100
TabIndex = 28
Top = 4850
Width = 1420
End
Begin VB.Label LblReceive
BackColor = &H0091CACA&
BorderStyle = 1 'Fixed Single
Caption = "接收区"
Height = 255
Left = 1130
TabIndex = 27
Top = 2180
Width = 595
End
End
Attribute VB_Name = "串口调试软件"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'=====================================================================================
' 变量定义
'=====================================================================================
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 ChkAutoSend_Click()
On Error GoTo Err
If ChkAutoSend.Value = 1 Then ' 如果有效则,自动发送
If MSComm.PortOpen = True Then ' 串口状态判断
TmrAutoSend.Interval = Val(TxtAutoSendTime) ' 设置自动发送时间
TmrAutoSend.Enabled = True ' 打开自动发送定时器
Else
ChkAutoSend.Value = 0 ' 串口没有打开去掉自动发送
MsgBox "串口没有打开,请打开串口", 48, "串口调试助手" ' 如果串口没有被打开,提示打开串口
End If
ElseIf ChkAutoSend.Value = 0 Then ' 如果无效,不发送
TmrAutoSend.Enabled = False ' 关闭自动发送定时器
End If
Err:
End Sub
'=====================================================================================
' 超链接我的博客
'=====================================================================================
Private Sub LblWeb_Click() ' 单击打开网站
ShellExecute Me.hwnd, "open", "http://blog.163.com/zhaojun_xf/", "", "", 5 ' 要打开的网站
End Sub
' 鼠标移入 WEB 区
Private Sub LblWeb_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
LblWeb.ForeColor = &H8A7839 ' 鼠标移入WEB时的颜色
LblWeb.MousePointer = 99 ' 鼠标移入WEB时的鼠标的现状 ,小手型
'LblWeb.MouseIcon = LoadPicture("f:\我的VB\串口调试软件\图片\mouse.cur") ' 鼠标形状图片
End Sub
' 鼠标移出 WEB 区
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
LblWeb.ForeColor = vbBlue ' 鼠标移出WEB时的颜色
Me.MousePointer = vbDefault ' 鼠标移出WEB时的鼠标的现状 即Me.MousePointer = 0
End Sub
'=====================================================================================
' 自动发送定时器
'=====================================================================================
Private Sub TmrAutoSend_Timer() ' 定时器
On Error GoTo Err
If TxtSend.Text = "" Then ' 判断发送数据是否为空
ChkAutoSend.Value = 0 ' 关闭自动发送
MsgBox "发送数据不能为空", 16, "串口调试助手" ' 发送数据为空则提示
Else
If ChkHexSend.Value = 1 Then ' 发送方式判断
MSComm.InputMode = comInputModeBinary ' 二进制发送
Call hexSend ' 发送十六进制数据
Else ' 按十六进制接收文本方式发送的数据时,文本也要按二进制发送发送
If ChkHexReceive.Value = 1 Then
MSComm.InputMode = comInputModeBinary ' 二进制发送
Else
MSComm.InputMode = comInputModeText ' 文本发送
End If
MSComm.Output = Trim(TxtSend.Text) ' 发送数据
ModeSend = False ' 设置文本发送方式
End If
End If
Err:
End Sub
'=====================================================================================
' 窗体载入
'=====================================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -