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

📄 main.frm

📁 VB代码
💻 FRM
📖 第 1 页 / 共 4 页
字号:
        End If
    Else
        FrmMain.LblOperationInfoDisp.Caption = "开始写加密位1"
        If (CMD_WriteLockBits(c_LockType_LockLevel1)) Then
            FrmMain.LblOperationInfoDisp.Caption = "写加密位1操作成功。"
        Else
            FrmMain.LblOperationInfoDisp.Caption = "写加密位1操作失败!"
        End If
        
        FrmMain.LblOperationInfoDisp.Caption = "开始写加密位2"
        If (CMD_WriteLockBits(c_LockType_LockLevel2)) Then
            FrmMain.LblOperationInfoDisp.Caption = "写加密位2操作成功。"
        Else
            FrmMain.LblOperationInfoDisp.Caption = "写加密位2操作失败!"
        End If
        
        FrmMain.LblOperationInfoDisp.Caption = "开始写加密位3"
        If (CMD_WriteLockBits(c_LockType_LockLevel3)) Then
            FrmMain.LblOperationInfoDisp.Caption = "写加密位3操作成功。"
        Else
            FrmMain.LblOperationInfoDisp.Caption = "写加密位3操作失败!"
        End If
        
    End If
End Sub

Private Sub MNU_Device_Program_Click()
    Dim bReturnValue As Boolean
    Dim ucSignatureDataBuff As String
    Dim iUserSelectValue As Integer
    
    FrmMain.LblOperationInfoDisp.Caption = "开始进行编程操作...编程数据缓冲区的起始6单元为:" _
    & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
    & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
    
    If (bReadDeviceSignatureFlag = False) Then
    
        bReturnValue = CMD_ReadSignature(ucSignatureDataBuff)
        If (StrComp(ucSignatureDataBuff, sCurrentDeviceSignatureString) <> 0) Then
            iUserSelectValue = MsgBox("读取到的设备特征字与编程器件不符,是否退出?", vbQuestion + vbYesNo + vbDefaultButton1, "请选择")
            If (iUserSelectValue = vbNo) Then
                If (CMD_WriteProgramMemory(lMaxCodeLength)) Then
                    FrmMain.LblOperationInfoDisp.Caption = "编程操作成功。"
                Else
                    FrmMain.LblOperationInfoDisp.Caption = "编程操作失败!"
                End If
            End If
        Else
            bReadDeviceSignatureFlag = True
            lblDeviceName.ForeColor = vbBlue
            
            If (CMD_WriteProgramMemory(lMaxCodeLength)) Then
                FrmMain.LblOperationInfoDisp.Caption = "编程操作成功。"
            Else
                FrmMain.LblOperationInfoDisp.Caption = "编程操作失败!"
            End If
        End If
        
    Else
        If (CMD_WriteProgramMemory(lMaxCodeLength)) Then
            FrmMain.LblOperationInfoDisp.Caption = "编程操作成功。"
        Else
            FrmMain.LblOperationInfoDisp.Caption = "编程操作失败!"
        End If
    End If
End Sub

Private Sub MNU_Device_Read_Click()
    Dim bReturnValue As Boolean
    Dim ucSignatureDataBuff As String
    Dim iUserSelectValue As Integer
   
    FrmMain.LblOperationInfoDisp.Caption = "开始执行读取芯片数据操作"
    
    If (bReadDeviceSignatureFlag = False) Then
         bReturnValue = CMD_ReadSignature(ucSignatureDataBuff)
         If (StrComp(ucSignatureDataBuff, sCurrentDeviceSignatureString) <> 0) Then

            iUserSelectValue = MsgBox("读取到的设备特征字与编程器件不符,是否退出?", vbQuestion + vbYesNo + vbDefaultButton1, "请选择")
            If (iUserSelectValue = vbNo) Then
                If (CMD_PageReadProgramMemory(lMaxCodeLength)) Then
            
                    FrmMain.LblOperationInfoDisp.Caption = "读取数据操作成功,读取到的数据区前6单元为:" _
                    & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
                    & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
                    
                    TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()
                Else
                    FrmMain.LblOperationInfoDisp.Caption = "读取芯片数据操作失败!"
                End If

            End If
        Else
            bReadDeviceSignatureFlag = True
            lblDeviceName.ForeColor = vbBlue
        
            If (CMD_PageReadProgramMemory(lMaxCodeLength)) Then
            
                FrmMain.LblOperationInfoDisp.Caption = "读取数据操作成功,读取到的数据区前6单元为:" _
                & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
                & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
                
                TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()
            Else
                FrmMain.LblOperationInfoDisp.Caption = "读取芯片数据操作失败!"
            End If

         End If
     Else
 
        If (CMD_PageReadProgramMemory(lMaxCodeLength)) Then
            
            FrmMain.LblOperationInfoDisp.Caption = "读取数据操作成功,读取到的数据区前6单元为:" _
            & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
            & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
            
            TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()
        Else
            FrmMain.LblOperationInfoDisp.Caption = "读取芯片数据操作失败!"
        End If

    End If
End Sub

Private Sub MNU_Device_Run_Click()
    FrmMain.LblOperationInfoDisp.Caption = "执行编程的相关功能......"

End Sub

Private Sub MNU_Device_Verify_Click()
    Dim bReturnValue As Boolean

    Dim bVerifyResult As Boolean
    Dim ucSignatureDataBuff As String
    Dim iUserSelectValue As Integer
    
    FrmMain.LblOperationInfoDisp.Caption = "开始进行编程数据的校验操作......"
    
    If (bReadDeviceSignatureFlag = False) Then
        bReturnValue = CMD_ReadSignature(ucSignatureDataBuff)
        If (StrComp(ucSignatureDataBuff, sCurrentDeviceSignatureString) <> 0) Then

            iUserSelectValue = MsgBox("读取到的设备特征字与编程器件不符,是否退出?", vbQuestion + vbYesNo + vbDefaultButton1, "请选择")
            If (iUserSelectValue = vbNo) Then
                bVerifyResult = CMD_PageVerifyProgramMemory(lMaxCodeLength)
         
                If (bVerifyResult) Then
                    FrmMain.LblOperationInfoDisp.Caption = "校验通过。"
                Else
                    FrmMain.LblOperationInfoDisp.Caption = "校验失败!"
                End If
            End If
        Else
            bReadDeviceSignatureFlag = True
            lblDeviceName.ForeColor = vbBlue
        
            bVerifyResult = CMD_PageVerifyProgramMemory(lMaxCodeLength)
             
            If (bVerifyResult) Then
                FrmMain.LblOperationInfoDisp.Caption = "校验通过。"
            Else
                FrmMain.LblOperationInfoDisp.Caption = "校验失败!"
            End If
        End If
    Else
    
        ' bVerifyResult = CMD_VerifyProgramMemory()
        bVerifyResult = CMD_PageVerifyProgramMemory(lMaxCodeLength)
         
        If (bVerifyResult) Then
            FrmMain.LblOperationInfoDisp.Caption = "校验通过。"
        Else
            FrmMain.LblOperationInfoDisp.Caption = "校验失败!"
        End If
    End If
End Sub

Private Sub MNU_Edit_Edit_Click()
    FrmMain.LblOperationInfoDisp.Caption = "开始执行编辑数据缓冲区操作"

End Sub

Private Sub MNU_Edit_FillBuff_Click()
Dim sFillBuffString As String
Dim ucFillData As Byte
Dim lCount As Long

    sFillBuffString = InputBox("请输入准备填充到缓冲区的值,16进制以&H开头", "请输入数字", "&HFF")
    
    If (Len(sFillBuffString) <> 0) Then
        If IsNumeric(sFillBuffString) Then
            ucFillData = CByte(sFillBuffString)
            
            For lCount = 0 To lMaxCodeLength - 1 Step 1
    
                ucDataBuff(lCount) = ucFillData
            Next lCount

        FrmMain.LblOperationInfoDisp.Caption = "完成填充缓冲区操作,缓冲区前6个单元为:" _
            & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
            & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
        
        TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()

        Else
            MsgBox "输入的数据不是有效数字,十六进行请用&H", vbOKOnly + vbCritical, "请检查 "
        End If
    End If

End Sub

Private Sub MNU_File_Exit_Click()
    Unload Me
    End
End Sub

Private Sub MNU_File_FileOpen_Click()
    Dim lFileLength As Long
    Dim lCount As Long
    Dim sFileName As String
    Dim ucFileNameLength As Byte
    Dim ucMsgBoxSelect As Byte
    Dim sFileExtName As String * 3
    Dim bResult As Boolean
    
    On Error GoTo ErrHandle
    
    FrmMain.LblOperationInfoDisp.Caption = "开始执行打开文件操作..."
    CommonDialog_PGMFile.Filter = "Hex文件(*.Hex)|*.Hex|Bin文件(*.bin)|*.Bin| All Files (*.*)|*.*"
    CommonDialog_PGMFile.FilterIndex = 1
    
    CommonDialog_PGMFile.ShowOpen
    
    
    sFileName = CommonDialog_PGMFile.FileName
    ucFileNameLength = Len(sFileName)
    If (ucFileNameLength < 5) Then
        ucMsgBoxSelect = MsgBox("文件名或文件名格式错误,请重新选择", vbCritical + vbOKOnly, "请注意")
        GoTo ErrHandle
    End If
    
    sFileExtName = LCase$(Right$(sFileName, 3))
    
    If (StrComp(sFileExtName, "bin") = 0) Then
        Open CommonDialog_PGMFile.FileName For Binary As #1
        lFileLength = LOF(1)
        
        For lCount = 0 To lMaxCodeLength Step 1
            ucDataBuff(lCount) = &HFF
        Next lCount
        
        If (lFileLength > lMaxCodeLength) Then
            lFileLength = lMaxCodeLength
        End If
        
        
        For lCount = 0 To lFileLength Step 1
            Get 1, lCount + 1, ucDataBuff(lCount)
        Next lCount
    
        Close (1)
    
    ElseIf (StrComp(sFileExtName, "hex") = 0) Then
    
        bResult = ConvertHexFileContentToDataBuff(sFileName)
        
    Else
        ucMsgBoxSelect = MsgBox("无效的文件扩展名", vbCritical + vbOKOnly, "请注意 ")
        GoTo ErrHandle
        
    End If
    
    FrmMain.LblOperationInfoDisp.Caption = "打开编程数据文件操作成功,编程数据缓冲区前6单元为:" _
    & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
    & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))
    
'    Call ConvertDataBuffContentToFormatString

   TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()
   Current_PGMSysInformation.PGMSysInfo_FileName = sFileName
   
   'Add conver full file name string to Display file name
   Current_PGMSysInformation.PGMSysInfo_DispFileName = sFileName
   Call RefreshPGMSysInfo
ErrHandle:
    Exit Sub
End Sub

Private Sub MNU_File_FileSave_Click()
 '   Txt_SysInfoDisp.Text = "Start Page Read Program Code"
    
 '   Call CMD_PageReadProgramMemory(lMaxCodeLength)
    
  '  Txt_SysInfoDisp.Text = "Read Program Code Complete,DataBuffer first six unit content is:" _
  '  & CStr_Hex(ucDataBuff(0)) & " " & CStr_Hex(ucDataBuff(1)) & " " & CStr_Hex(ucDataBuff(2)) _
  '  & " " & CStr_Hex(ucDataBuff(3)) & " " & CStr_Hex(ucDataBuff(4)) & " " & CStr_Hex(ucDataBuff(5))

   ' TxtDataBuffDispBox.Text = ConvertDataBuffContentToFormatString()

    'Txt_SysInfoDisp.Text = "Page Read Complete"
End Sub

Private Sub MNU_Help_About_Click()
    FrmAboutSoft.Show vbModal
End Sub

Private Sub MNU_Help_Service_Click()
    MsgBox ("感谢你的使用,请你提出宝貴的意见或建议" & vbCrLf _
    & "联系方式e_Mail: xg_2004_sy@126.com" & vbCrLf _
    & "联系电话:025-51615878")
End Sub

Private Sub MNU_ReadDeviceSignature_Click()
    Dim ucSignatureDataBuff As String
    Dim bReturnValue As Boolean
    
    FrmMain.LblOperationInfoDisp.Caption = "开始读取设备特征字..."
   
    'bReturnValue = ReadDeivceSignature(ucDataBuff)
    bReturnValue = CMD_ReadSignature(ucSignatureDataBuff)
    If (bReturnValue) Then
        FrmMain.LblOperationInfoDisp.Caption = "读取到的设备特征字为:" & ucSignatureDataBuff
        
        '对设备特征字进行检测
        If (StrComp(ucSignatureDataBuff, sCurrentDeviceSignatureString) <> 0) Then
            Call BeepShort
            MsgBox "读取到的设备特征字与所选编程器件不符", vbQuestion + vbYes, "请注意"
        Else
            bReadDeviceSignatureFlag = True
            lblDeviceName.ForeColor = vbBlue
    
        End If
   
    Else
    
    End If
        
End Sub

Private Sub MNU_Select_SetAutoExecOption_Click()
    FrmSetAutoExecOption.Show vbModal, FrmMain
End Sub

Private Sub MNU_Select_SetCommPort_Click()
   FrmMain.LblOperationInfoDisp.Caption = "正在查找串行通讯口,请稍候......"
    FrmMain.LblOperationInfoDisp.Refresh
    
    FrmOption.Show vbModal, FrmMain
    FrmMain.LblOperationInfoDisp.Caption = "设置操作完成"
 
End Sub

Private Sub MNU_Select_TestOnLine_Click()
    FrmMain.LblOperationInfoDisp.Caption = "正在测试联机操作"
    If (TestProgramDeviceHardWare()) Then
        FrmMain.LblOperationInfoDisp.Caption = "联机测试成功"
    Else
        FrmMain.LblOperationInfoDisp.Caption = "联机测试失败"
    End If

End Sub

Private Sub TmrComReceive_Timer()
    TmrComReceive.Enabled = False
    bComReceiveTimeOut = True
End Sub

⌨️ 快捷键说明

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