📄 参数检测单元检测板.frm
字号:
End
Begin VB.Menu sendtxt
Caption = "发送文本文件"
End
Begin VB.Menu vbfas
Caption = "-"
End
Begin VB.Menu anjian
Caption = "按键即发送(在接收框)"
Checked = -1 'True
End
End
Begin VB.Menu bangzhu
Caption = "帮助"
Begin VB.Menu chuankoushuoming
Caption = "串口数据调试器操作说明"
End
Begin VB.Menu shaoxieshuoming
Caption = "51串行烧写器操作说明"
End
Begin VB.Menu tupian
Caption = "51串行烧写器图片"
End
Begin VB.Menu qwetqg
Caption = "-"
End
Begin VB.Menu guanyu
Caption = "关于本软件"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public ansiTxt As String '从文件中读入的字符串
Public ifhex As Long '显示方式hex还是ascii
Public inData As String '串口中断时读入的字符串
Public savetime '选定文件的最新更改时间
Public JustsendHex As String
Public Justsendasc As String
Private ExitFlag As Boolean
Private Sub anjian_Click()
If anjian.Checked Then anjian.Checked = False Else anjian.Checked = 1
End Sub
Private Sub bt_Click(Index As Integer)
'On Error Resume Next
If MSComm1.PortOpen Then
Dim i As Integer
While i < 10
bt(i).Checked = False
i = i + 1
Wend
bt(Index).Checked = True
MSComm1.PortOpen = False
Select Case Index
Case 0
MSComm1.Settings = "300,,,"
Case 1
MSComm1.Settings = "600,,,"
Case 2
MSComm1.Settings = "1200,,,"
Case 3
MSComm1.Settings = "2400,,,"
Case 4
MSComm1.Settings = "4800,,,"
Case 5
MSComm1.Settings = "9600,,,"
Case 6
MSComm1.Settings = "19200,,,"
Case 7
MSComm1.Settings = "38400,,,"
Case 8
MSComm1.Settings = "57600,,,"
Case 9
MSComm1.Settings = "115200,,,"
End Select
MSComm1.PortOpen = 1
Else
MsgBox ("串口设备未打开!")
End If
End Sub
Private Sub Check4_Click()
If Check4.Value Then
Timer3.Enabled = 1
Command7.Enabled = 0
Text4.Enabled = 1
Else
Timer3.Enabled = 0
Text4.Enabled = 0
Command7.Enabled = 1
End If
End Sub
Private Sub chuankoushuoming_Click()
Text1.Text = " 串口数据调试软件说明" & vbCrLf _
& " 我想这个串口调试软件应该是每个人都能一看就会,时间仓促,详细的说明就在正式版推出时再写吧。" & vbCrLf _
& " 这里只不过要提示几点:" & vbCrLf _
& " 1.串口的状态和波特率及是否打开在标题栏有显示。" & vbCrLf _
& " 2.使用的串口速度要根据你的机器速度,太慢的机器使用115200bps可能要溢出。我试验一般的机器都可以达到57600bps连续数据长期运作不死机。具体效果你可以自己试一下" & vbCrLf _
& " 3.发送hex数据串时,每个数据一定要有两个字母,如‘a’必须写成‘0a’,而且每个数据之间有一个空格。" & vbCrLf _
& " 4.双击接收框也可以更换HEX或者ASC显示方式。" & vbCrLf _
& " 5.更改窗口大小时最好先关闭串口,特别是高速率正在接收时。否则可能引起溢出出错。" & vbCrLf _
& " 6.这个软件可以显示接收到中文数据,一般的可没有哟。用得好请给我来信,让我高兴一下,用得不好就通知我更改吧。"
End Sub
Private Sub clearwin_Click()
Text1.Text = ""
End Sub
Private Sub closecom_Click()
Command19_Click
End Sub
Private Sub Combo1_Click()
If Combo1.Text = "AT89C2051" Then MsgBox ("请将右边的四个插针放在2051位置。用完后要写40脚芯片请插回51位置。")
If Combo1.Text = "AT89C1051" Then MsgBox ("请将右边的四个插针放在2051位置。用完后要写40脚芯片请插回51位置。")
If Combo1.Text = "W78E58" Then
MsgBox ("请将左边的一个插针放在‘W’位置。用完后要写其他芯片请插回。")
End If
End Sub
Private Sub comm1_Click()
If MSComm1.PortOpen Then
MSComm1.PortOpen = 0
MSComm1.CommPort = 1
MSComm1.PortOpen = True
comm1.Checked = 1
comm2.Checked = 0
Else
MsgBox ("串口设备未打开!")
End If
End Sub
Private Sub comm2_Click()
If MSComm1.PortOpen Then
MSComm1.PortOpen = 0
MSComm1.CommPort = 2
MSComm1.PortOpen = True
comm1.Checked = 0
comm2.Checked = 1
Else
MsgBox ("串口设备未打开!")
End If
End Sub
Private Sub Command1_Click()
Picture1.Visible = 0
Command1.Visible = 0
End Sub
Private Sub Command10_Click()
On Error Resume Next
MSComm1.Output = "`"
End Sub
Private Sub Command11_Click()
On Error Resume Next
MSComm1.Output = "a"
End Sub
Private Sub Command13_Click()
Command14_Click
End Sub
Private Sub Command14_Click()
On Error Resume Next
Dim name As String
'name = InputBox("请输入保存的文件名:")
'If name <> "" Then
CommonDialog1.filename = "c:\windows\desktop\a"
CommonDialog1.InitDir = "c:\windows\desktop\"
CommonDialog1.ShowSave
If Err.Number <> 32755 Then 'cacel处理
Dim fileNo As Integer '
fileNo = FreeFile
Open CommonDialog1.filename For Output As #fileNo
Print #fileNo, Text1.Text
Close #fileNo '关闭文件
Else
CommonDialog1.filename = ""
End If
'End If
End Sub
Private Sub Command15_Click()
On Error Resume Next
MSComm1.Output = "s3"
End Sub
Private Sub Command16_Click()
On Error Resume Next
MsgBox ("只能解部分at89c51和at89c52的密!请先放好芯片。")
MSComm1.Output = "j"
End Sub
Private Sub Command17_Click()
Text2.Text = ""
End Sub
Private Sub Command18_Click()
On Error Resume Next
MSComm1.PortOpen = 1
opencom.Checked = 1
closecom.Checked = 0
Command18.Enabled = 0
Command19.Enabled = 1
End Sub
Private Sub Command19_Click()
On Error Resume Next
MSComm1.PortOpen = 0
closecom.Checked = 1
opencom.Checked = False
Command18.Enabled = 1
Command19.Enabled = 0
End Sub
Private Sub Command2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
Dim inAsc As String
Dim outHex As Integer
Dim outHex1 As Integer
Dim i As Integer
Dim ouTputHex(0) As Byte
While i < Len(Text2.Text)
outHex = Str_Int(Mid(Text2.Text, i + 1, 1))
' If outHex = -1 Then
' MsgBox "输入错误"
' Else
outHex = outHex * 16
' End If
outHex1 = Str_Int(Mid(Text2.Text, i + 2, 1))
' If outHex1 = -1 Then
' MsgBox "输入错误"
' Else
ouTputHex(0) = outHex + outHex1
' End If
i = i + 3
MSComm1.Output = ouTputHex()
'Text1.Text = Text1.Text & outHex & " "
Wend
Else: MSComm1.Output = Text1.Text '将显示出的内容发出到串口
End If
End Sub
Function Str_Int(a As String) As Integer '字符转换成hex码
Select Case a
Case "0" To "9"
Str_Int = Asc(a) - 48
Case "A" To "F"
Str_Int = Asc(a) - 55
Case "a" To "f"
Str_Int = Asc(a) - 87
Case Else
Str_Int = 0
End Select
End Function
Function delay(t As Long) As Integer
Dim i As Long
Dim j As Long
For i = 0 To t
DoEvents
For j = 0 To 10000
DoEvents
If ExitFlag Then
End
End If
Next j
Next i
End Function
Private Sub Command4_Click()
'打开文件按纽
On Error Resume Next
CommonDialog1.ShowOpen
If Err.Number = 32755 Then 'cacel处理
CommonDialog1.filename = ""
End If
Text3.Text = CommonDialog1.filename '取出文件名
Dim fileNo As Integer '以二进制方式读取文件
fileNo = FreeFile
Open Text3.Text For Binary As #fileNo
'ProgressBar1.Max = LOF(fileNo) + 1'进度条
'ProgressBar1.Value = 1
ansiTxt = Input(LOF(fileNo), fileNo) '读入文件内容
'ProgressBar1.Value = ProgressBar1.Max
Text1.Text = ansiTxt & vbCrLf & "共 " & LOF(fileNo) & " bytes" & vbCrLf & vbCrLf '显示出来
Text1.SelStart = Len(Text1.Text) '光标置后
Close #fileNo '关闭文件
savetime = FileDateTime(Text3.Text) '取文件保存时间
End Sub
Private Sub Command5_Click()
If MSComm1.PortOpen Then
Command5.Enabled = 0
Dim j As Long
While j <= Len(ansiTxt)
DoEvents
MSComm1.Output = Mid(ansiTxt, j + 1, 1)
j = j + 1
Wend
Command5.Enabled = 1
Else: MsgBox ("串口设备没打开!")
End If
If ansiTxt = "" Then MsgBox ("还没有选择好要烧写的文件。")
End Sub
Private Sub Command7_Click()
On Error Resume Next
If Option1.Value Then
Dim inAsc As String
Dim outHex As Integer
Dim outHex1 As Integer
Dim i As Integer
Dim ouTputHex(0) As Byte
While i < Len(Text2.Text)
outHex = Str_Int(Mid(Text2.Text, i + 1, 1))
'If outHex = -1 Then
' MsgBox "输入错误"
'Else
outHex = outHex * 16
'End If
outHex1 = Str_Int(Mid(Text2.Text, i + 2, 1))
'If outHex1 = -1 Then
' MsgBox "输入错误"
'Else
ouTputHex(0) = outHex + outHex1
'End If
i = i + 3
MSComm1.Output = ouTputHex()
'Text1.Text = Text1.Text & outHex & " "
Wend
JustsendHex = Text2.Text
Else
MSComm1.Output = Text2.Text
Justsendasc = Text2.Text
End If
End Sub
Private Sub Command9_Click()
Text1.Text = ""
End Sub
Private Sub Form_Load()
On Error Resume Next
MSComm1.CommPort = 1
MSComm1.InputLen = 0 '设置每次从串口缓冲区取的字节为全部
MSComm1.InputMode = comInputModeBinary
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True '打开串口
JustsendHex = "fe ff 12 0a 0d 1b "
Text2.Text = JustsendHex
Justsendasc = "0123456789abcdefg"
'Command4.SetFocus
tiaoshiqi_Click
If MSComm1.PortOpen Then Command18.Enabled = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -