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

📄 form2.frm

📁 密码加密解密的各种算法,可以实现单片机的密码保护算发
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   8760
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   10260
   LinkTopic       =   "Form1"
   ScaleHeight     =   8760
   ScaleWidth      =   10260
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command4 
      Caption         =   "发送"
      Height          =   495
      Left            =   8400
      TabIndex        =   20
      Top             =   6480
      Width           =   1695
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   12
      Left            =   9120
      TabIndex        =   19
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   11
      Left            =   8370
      TabIndex        =   18
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   10
      Left            =   7620
      TabIndex        =   17
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   9
      Left            =   6870
      TabIndex        =   16
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   8
      Left            =   6120
      TabIndex        =   15
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   7
      Left            =   5370
      TabIndex        =   14
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   6
      Left            =   4620
      TabIndex        =   13
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   5
      Left            =   3870
      TabIndex        =   12
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   4
      Left            =   3120
      TabIndex        =   11
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   3
      Left            =   2370
      TabIndex        =   10
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   2
      Left            =   1620
      TabIndex        =   9
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   1
      Left            =   870
      TabIndex        =   8
      Top             =   6000
      Width           =   615
   End
   Begin VB.TextBox Text5 
      Height          =   270
      Index           =   0
      Left            =   120
      TabIndex        =   7
      Top             =   6000
      Width           =   615
   End
   Begin VB.CommandButton Command3 
      Caption         =   "清除"
      Height          =   375
      Left            =   4560
      TabIndex        =   6
      Top             =   7560
      Width           =   1095
   End
   Begin VB.CommandButton Command2 
      Caption         =   "显示"
      Height          =   495
      Left            =   3000
      TabIndex        =   5
      Top             =   7320
      Width           =   855
   End
   Begin VB.Timer Timer1 
      Interval        =   3000
      Left            =   6840
      Top             =   7800
   End
   Begin VB.TextBox Text4 
      Height          =   2175
      Left            =   120
      MultiLine       =   -1  'True
      TabIndex        =   4
      Text            =   "Form2.frx":0000
      Top             =   2760
      Width           =   7335
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   8880
      TabIndex        =   3
      Text            =   "Text3"
      Top             =   2880
      Width           =   1215
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   8400
      Top             =   1560
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
   End
   Begin VB.CommandButton Command1 
      Caption         =   "发送"
      Height          =   975
      Left            =   7680
      TabIndex        =   2
      Top             =   240
      Width           =   2295
   End
   Begin VB.TextBox Text2 
      Height          =   1455
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   1
      Text            =   "Form2.frx":0006
      Top             =   1080
      Width           =   7455
   End
   Begin VB.TextBox Text1 
      Height          =   735
      Left            =   0
      MultiLine       =   -1  'True
      TabIndex        =   0
      Text            =   "Form2.frx":000C
      Top             =   120
      Width           =   7455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim data_in(2), temp As Byte
Dim data_out(14) As Byte
Dim indata As Variant
Dim flay_start As Boolean
Dim commrec_flag As Boolean
Dim i, j, recelen As Integer
Dim asa() As Byte
Dim rec_count As Integer
Dim bb As String
Dim aa As Byte

Private Sub Command1_Click()
If MSComm1.PortOpen = False Then MSComm1.PortOpen = True    '打开串口
Dim a As Integer
data_out(0) = &HAA
data_out(1) = &HAA
data_out(2) = &HAA
data_out(3) = &H0
data_out(4) = &H11
data_out(5) = &H2
data_out(6) = &H23
data_out(7) = &H0
data_out(8) = &H0
data_out(9) = &H0
data_out(10) = &H0
data_out(11) = &H0
data_out(12) = &H0
data_out(13) = &H1
data_out(14) = &H3
For i = 0 To 14
    Text1.Text = Text1.Text & Hex(data_out(i)) & " "
Next i
MSComm1.Output = data_out

Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
If MSComm1.PortOpen = False Then MSComm1.PortOpen = True    '打开串口
'Timer1.Enabled = False
Dim temp As Integer
Text4.Text = Text4.Text & Chr(13) & Chr(10)
For temp = 0 To 12
    Text4.Text = Text4.Text & Hex(data_in(temp)) & " "
Next temp
End Sub

Private Sub Command3_Click()
Dim temp As Integer
For temp = 0 To 2
    data_in(temp) = &H0
Next temp
End Sub



Private Sub Form_Load()
MSComm1.CommPort = 1                '使用串口1
MSComm1.Settings = "9600,N,8,1"     '打开串口1,准备数据通信
MSComm1.OutBufferSize = 65          '定义发送数据缓冲区
MSComm1.InBufferSize = 65           '定义接收数据缓冲区
MSComm1.InBufferCount = 0           '输入缓冲计数器清0
MSComm1.OutBufferCount = 0          '输出缓冲计数器清0
MSComm1.InputMode = comInputModeBinary  '文本方式进行传输,二进制方式传输可以直接转换
'If MSComm1.PortOpen = False Then MSComm1.PortOpen = True    '打开串口
MSComm1.InputLen = 15             '定义输入的字符大小
MSComm1.RThreshold = 2           '定义每次ONCOMM事件触发值
Text2.Text = ""
Text1.Text = ""
Text4.Text = ""
commrec_flag = False
Timer1.Enabled = True
If MSComm1.PortOpen = False Then MSComm1.PortOpen = True    '打开串口
End Sub

Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
    Case comEvReceive:
    Do
        DoEvents
    Loop Until MSComm1.InBufferCount >= 3
    indata = MSComm1.Input
    'MSComm1.InBufferCount = 0
    For i = 0 To 2
        data_in(i) = indata(i)
        Text2.Text = Text2.Text & Hex(data_in(i)) & " "
    Next i
    commrec_flag = True
End Select
End Sub

Private Sub Timer1_Timer()
Dim temp As Integer
Text4.Text = Text4.Text & Chr(13) & Chr(10)
For temp = 0 To 2
    Text4.Text = Text4.Text & Hex(data_in(temp)) & " "
Next temp
Timer1.Enabled = False
End Sub

Private Sub dataret()
Dim le, ri, ll As String
    If bb = "" Then
        aa = 0
        
        Exit Sub
    End If
    ll = Len(bb)
    le = UCase(Mid(bb, 1, 1))
    ri = UCase(Mid(bb, 2, 1))
    If ll = 1 Then
        le = "0"
        ri = UCase(Mid(bb, 1, 1))
    End If
    If le >= "0" And le <= "9" Then
        le = Asc(le) - &H30
    ElseIf le >= "A" And le <= "F" Then
        le = Asc(le) - &H37
    Else
        MsgBox "错误,请确认输入"
        Exit Sub
    End If
    If ri >= "0" And ri <= "9" Then
        ri = Asc(ri) - &H30
    ElseIf ri >= "A" And ri <= "F" Then
        ri = Asc(ri) - &H37
    Else
        MsgBox "错误,请确认输入"
        Exit Sub
    End If
    aa = le * 16 + ri
    
End Sub

Private Sub Command4_Click()
If MSComm1.PortOpen = False Then MSComm1.PortOpen = True    '打开串口
Dim temp, temp1 As Integer
For temp = 0 To 12
    bb = Text5(temp).Text
    Call dataret
    data_out(2 + temp) = aa
    Text1.Text = Text1.Text & Hex(aa) & " "
Next temp
data_out(0) = &HAA
data_out(1) = &HAA
MSComm1.Output = data_out
Timer1.Enabled = True
End Sub

⌨️ 快捷键说明

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