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

📄 参数检测单元检测板.frm

📁 简单编程器的界面程序
💻 FRM
📖 第 1 页 / 共 3 页
字号:
Private Sub Command3_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim sendbyte(1) As Byte
sendbyte(0) = 27
sendbyte(1) = 27
If Button = 2 Then '右健停止读取串口


MSComm1.Output = sendbyte
Else: Text1.Text = "" '左键清除
MSComm1.Output = sendbyte
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ExitFlag = True
End Sub



Private Sub guanyu_Click()
MsgBox ("southstar串口测试 & 51烧写器v1.0测试版。" & vbCrLf & "丁丁硬件开发工作室制作,作者聂小猛。" & vbCrLf & "要了解该软件的详细信息或升级情况请访问作者主页:" & vbCrLf & "51单片机世界 http://mcu51.126.com " & vbCrLf & "欢迎对此软件提出修改建议!" & vbCrLf & "作者Email:mcu51@163.com")
End Sub
Private Sub Form_Resize() '窗体改变时
On Error Resume Next


Text1.Width = Form1.Width - 80 '文本框跟着改变
If shaoxie.Checked Then
Text1.Height = Form1.Height - 1300
Else
Text1.Height = Form1.Height - 2100
End If
Text2.Width = Form1.Width - 1500
Text2.Top = Form1.Height - 1200
Label1.Top = Form1.Height - 1450
Frame1.Top = Form1.Height - 1450

Check4.Top = Form1.Height - 1500
Check4.Left = Form1.Width - 1450
Text4.Top = Form1.Height - 1200
Text4.Left = Form1.Width - 1450
Command7.Top = Form1.Height - 950
Command7.Left = Form1.Width - 1450
Command17.Top = Form1.Height - 950
Command17.Left = Form1.Width - 1450 + Command7.Width
Label2.Top = Form1.Height - 1200
Label2.Left = Form1.Width - 1400 + Command7.Width

End Sub


Private Sub MSComm1_OnComm() '串口中断
'On Error Resume Next
Static bFlag As Boolean
Static Xbyte As Long
Select Case MSComm1.CommEvent '选择事件
Case comEvReceive '接收到字符

        Dim InByte() As Byte '定义一个二进制指针放接收到的数据
        InByte = MSComm1.Input '数据转移到指针
        Dim temp As Long
        Dim temp1 As Long
        Dim temp2 As Long
        Dim j As Long
      
         For j = 0 To UBound(InByte) '循环到指针上标
            If ifhex = 1 Then '16进制显示处理
            inData = inData & Hex(InByte(j)) & " " '取出一个字节换为16进制显示用

            Else:
                  If InByte(j) < 128 And bFlag = 0 Then
                    If InByte(j) = 13 Then
                    inData = inData & vbCr 'Lf
                    Else
                    inData = inData & Chr(InByte(j)) 'ascii码显示处理
                    End If
                  Else '此时为一个中文的前半部
                     If bFlag Then '上次收到半个中文没处理
                     temp1 = Xbyte
                     temp2 = InByte(j)
                     temp = (temp1 * 256 + temp2) - 65536
                     inData = inData & Chr(temp)
                     bFlag = 0
                     Else
                        If j <> UBound(InByte) Then
                        temp1 = InByte(j)
                        temp2 = InByte(j + 1)
                        temp = (temp1 * 256 + temp2) - 65536
                        inData = inData & Chr(temp) ' & "(*" & temp & "*) "
                        j = j + 1 '此次中断收到最后一个字节是前半个中文
                        Else
                        
                        Xbyte = InByte(j) '保存该字节
                        bFlag = 1 '置标志
                        
                        End If
                     End If
                  End If
            End If
         Next j

 DoEvents


    Text1.SelText = inData '将刚收到的字符串显示出来
    inData = ""
  Text1.SelStart = Len(Text1.Text) '光标置后
    
Case comEventRxOver '接收缓冲区满的处理
MsgBox "接收缓冲区满了!" '发出警告
End Select
End Sub



Function Beep_(i As Long)
Dim j As Long
For j = 0 To i
Beep
DoEvents
Next j
End Function

Private Sub opencom_Click()
Command18_Click
End Sub

Private Sub Option1_Click()
Text2.Text = JustsendHex
End Sub

Private Sub Option2_Click()
Text2.Text = Justsendasc
End Sub

Private Sub Option3_Click()
ifhex = 0
End Sub

Private Sub Option4_Click()
ifhex = 1
End Sub

Private Sub qingchu_Click()
Text1.Text = ""
End Sub

Private Sub savechuangkou_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 sendasc_Click()
Option2_Click
Option2.Value = 1
Option1.Value = 0
End Sub

Private Sub sendhex_Click()
Option1_Click
Option2.Value = 0
Option1.Value = 1
End Sub

Private Sub sendtxt_Click()
If Not MSComm1.PortOpen Then
MsgBox ("串口设备未打开!")
Else
    On Error Resume Next
    CommonDialog1.ShowOpen
    If Err.Number = 32755 Then 'cacel处理
    CommonDialog1.filename = ""
    End If
        Dim fileNo As Integer '以二进制方式读取文件
        fileNo = FreeFile
        Open CommonDialog1.filename 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 '关闭文件
    
    Text1.Text = Text1.Text & vbCrLf & "正在发送......"
    Text1.SelStart = Len(Text1.Text)
      Dim j As Long
            While j <= Len(ansiTxt)
            DoEvents
            MSComm1.Output = Mid(ansiTxt, j + 1, 1)
            j = j + 1
            Wend
    Command5.Enabled = 1
    Text1.Text = Text1.Text & vbCrLf & "发送完毕!"
    Text1.SelStart = Len(Text1.Text)

End If
End Sub

Private Sub shaoxie_Click()
tiaoshiqi.Checked = 0
shaoxie.Checked = True
fasong.Enabled = 0
Text1.Height = Form1.Height - 1300

Command18.Visible = 0
Command19.Visible = 0
Command9.Visible = 0
Option3.Visible = 0
Option4.Visible = 0
Command4.Visible = 1
Text3.Visible = 1
Check2.Visible = 1
Combo1.Visible = 1
Command5.Visible = 1
Command10.Visible = 1
Command11.Visible = 1
Command15.Visible = 1
Command16.Visible = 1
Label1.Visible = 0
Option1.Visible = 0
Option2.Visible = 0
Frame1.Visible = 0
Check4.Visible = 0
Text2.Visible = 0
Text4.Visible = 0
Label2.Visible = 0
Command7.Visible = 0
Command17.Visible = 0
End Sub



Private Sub shaoxieshuoming_Click()
Text1.Text = "   51串行烧写器操作简易说明" & vbCrLf _
& "   请选择菜单上的“功能\51串口烧写器”使本软件处在烧写器状态。" & vbCrLf _
& "   普通烧写方式:" & vbCrLf _
& "   1。将51串口烧写器接在com1口,如接在com2口请按“串口设置\端口”重新设置,接上USB插头(利用它供5v电源),此时接收窗将出现开机提示。" & vbCrLf _
& "   2。插好芯片,在芯片选择框里选好你要烧的芯片。(此操作仅提示跳线状态,熟练操作后知道如何跳线可不作选择) " & vbCrLf _
& "   3。按“打开文件”键,打开要烧写的HEX目标烧写文件。" & vbCrLf _
& "   4。按“开始烧写”键开始烧写,窗口中将出现返回的状态信息。" & vbCrLf & vbCrLf _
& "   编译完立即烧写(支持所有51编译系统): " & vbCrLf _
& "   1。设置好你的51编译系统,编译完立即生成一个新的hex目标烧写文件。 " & vbCrLf _
& "   2。点击选项“自动烧写”,使前面的框中出现“X”号。" & vbCrLf _
& "   3。按“打开文件”键,打开你要烧写的HEX目标烧写文件,如果不存在,请编译一次以生成该文件。" & vbCrLf _
& "   4。此时可将本软件放在后台,去编译你的51源程序,只要你编译出了新的这个目标hex文件,就会自动将该文件发往串口烧写一遍。可要记住,一定要先放好芯片哟。 " & vbCrLf & vbCrLf _
& "   加密操作: " & vbCrLf _
& "   按“开始加密”键进行所有共三级加密。" & vbCrLf _
& "   解密操作:" & vbCrLf _
& "   按“开始解密”键进行解密,仅对部分atmel51,52芯片有效。仅供玩玩而已,本人申明不对解出的数据负责!" & vbCrLf _
& "   芯片插入方向:" & vbCrLf _
& "   同监控芯片方向,20脚芯片与40脚芯片1号脚对齐。" & vbCrLf _
& "   更详细的帮助信息请看说明书,或到http://mcu51.126.com查看。" & vbCrLf
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
On Error Resume Next
If anjian.Checked Then MSComm1.Output = Chr(KeyAscii)
End Sub

Private Sub tiaoshiqi_Click()
tiaoshiqi.Checked = 1
shaoxie.Checked = 0
fasong.Enabled = 1
Text1.Height = Form1.Height - 2100

Command18.Visible = 1
Command19.Visible = 1
Command9.Visible = 1
Option3.Visible = 1
Option4.Visible = 1
Command4.Visible = 0
Text3.Visible = 0
Check2.Visible = 0
Combo1.Visible = 0
Command5.Visible = 0
Command10.Visible = 0
Command11.Visible = 0
Command15.Visible = 0
Command16.Visible = 0
Label1.Visible = 1
Option1.Visible = 1
Option2.Visible = 1
Frame1.Visible = 1
Check4.Visible = 1
Text2.Visible = 1
Text4.Visible = 1
Label2.Visible = 1
Command7.Visible = 1
Command17.Visible = 1
End Sub

Private Sub Text1_DblClick() '转换显示方式
If ifhex = 1 Then
ifhex = 0
Option3.Value = 1
Option4.Value = 0
Else: ifhex = 1
Option4.Value = 1
Option3.Value = 0
End If
End Sub


Private Sub Timer1_Timer() '十毫秒定时中断,用于刷新字符显示
        
        '  Text1.SelStart = Len(Text1.Text) '光标置后
         
     If Len(Text1.Text) > 32000 Then   '文本太长清空
    Text1.Text = "对不起,文本太大,故清空。"
    Text1.SelStart = 0
    End If
  Dim iSopen As String
  If MSComm1.PortOpen Then iSopen = ",opened" Else iSopen = ",closed"

' Form1.Caption = Form1.Caption & ", close"
If Command5.Enabled Then
Form1.Caption = "当前使用端口:COM" & MSComm1.CommPort & "," & MSComm1.Settings & iSopen '显示串口状态
Else
Form1.Caption = "正在烧写!!!!!!!当前使用端口:COM" & MSComm1.CommPort & "," & MSComm1.Settings & iSopen '显示串口状态
End If
     If Check2.Value = 0 Then '自动烧写方式打开1秒定时器
    Timer2.Enabled = 0
    Else: Timer2.Enabled = 1
    End If
'Text2_GotFocus
End Sub


Private Sub Timer2_Timer() '1秒定时器
On Error Resume Next '处理打不开文件时出错
Dim savetime0
Dim i As Long
Dim fileNo As Integer '读入文件
    fileNo = FreeFile
    Open Text3.Text For Binary As #fileNo 'text3.text是被烧写文件名。
    i = LOF(fileNo)
savetime0 = FileDateTime(Text3.Text) '比较
If savetime <> savetime0 And i <> 0 Then

   '文件新修改,开始烧写
        ansiTxt = Input(LOF(fileNo), fileNo)
        Text1.Text = ansiTxt & vbCrLf & "文件大小 " & LOF(fileNo) & " bytes" & vbCrLf
        Text1.SelStart = Len(Text1.Text)
        Dim j As Long
        While j <= Len(ansiTxt)
        DoEvents
        MSComm1.Output = Mid(ansiTxt, j + 1, 1)
        j = j + 1
        Wend
End If
Close #fileNo
If i <> 0 Then
savetime = savetime0 'FileDateTime(Text3.Text) '保存此次修改时间
End If
'Text1.Text = Text1.Text & vbCrLf & savetime & vbCrLf & savetime0
'Text1.SelStart = Len(Text1.Text)
End Sub

Private Sub Timer3_Timer()
Command7_Click
If Text4.Text <> "" And Val(Text4.Text) <> 0 And Val(Text4.Text) < 65500 Then Timer3.Interval = Val(Text4.Text)
End Sub

Private Sub tupian_Click()
Picture1.Visible = 1
Command1.Visible = 1
Text1.Text = "专门为51开发工程师设计的51专用烧写器!" & vbCrLf _
& "可以编译完立即烧写!支持任何51编译系统!大量节省您的设计开发时间!" & vbCrLf _
& "体积小巧,至今没有任何烧写器可比!" & vbCrLf _
& "采用USB电源,内部升压,携带更方便!" & vbCrLf _
& "可以支持几个公司的多种51芯片:AT89C51,AT89C52,AT89C1051,AT89C2051,AT80F51,AT80F52,AT87F51,AT87F52,W78E51,W78E52,W78E58,甚至支持最新的W77E58!" & vbCrLf _
& "价格仅一百来元,而且都包邮费和连线。" & vbCrLf _
& "去访问“51单片机世界”http://mcu51.126.com看看吧,说不定还有更好的东西等着您呢~v~,祝你好运!" & vbCrLf
End Sub

⌨️ 快捷键说明

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