幽冥大陆(七)安诺克酒店智能门锁SDKV3 VBDemo—东方仙盟 - 教程

news/2025/9/26 13:36:05/文章来源:https://www.cnblogs.com/yxysuanfa/p/19113315

文件列表

dll引用 Module1.bas

Attribute VB_Name = "Module1"
Option Explicit
'*************************************************************************
'*  链接卡片操作函数库
'*************************************************************************
Public Declare Function mif_selecom Lib "LCRFRW_SDK.dll" (ByVal com As Long, ByVal baud As Long) As Long
Public Declare Function mif_selecard Lib "LCRFRW_SDK.dll" (ByVal ncardtype As Long) As Long
Public Declare Function mif_closecom Lib "LCRFRW_SDK.dll" () As Long
Public Declare Function tem_writedoorcard13_sdk Lib "LCRFRW_SDK.dll" (ByVal buffer1$, ByVal buffer2$, ByVal xh As Long, ByVal sjdw As Long, ByVal sjlenght As Long, ByVal gs As Long, ByVal p_nLockAP As Long, ByVal tfzd As Long, ByVal gs As Boolean) As Long
Public Declare Function tem_readdoorcard_sdk Lib "LCRFRW_SDK.dll" (ByVal buffer1$, ByVal buffer2$, ByVal p_nLockAP As Long) As Long
Public Declare Function tem_readtimercard_sdk Lib "LCRFRW_SDK.dll" (ByVal fksj$, ByVal time$, ByVal p_nLockAP As Long) As Long
Public Declare Function tem_writetimercard_sdk Lib "LCRFRW_SDK.dll" (ByVal fksj$, ByVal nxh As Long, ByVal time$, ByVal p_nLockAP As Long) As Long
Public Declare Function tem_readidcard_sdk Lib "LCRFRW_SDK.dll" (ByVal idbuff$) As Long
Public Declare Function tem_readdatetime13_sdk Lib "LCRFRW_SDK.dll" (ByVal p_csStartTime$, ByVal p_nUnit$, ByVal p_nTimes$, ByVal p_CheckOutHour$, ByVal p_OpenInner$, ByVal p_nLockAP As Long) As Long

窗口代码

VERSION 5.00
Begin VB.Form Form1
BorderStyle     =   3  'Fixed Dialog
Caption         =   "感应门锁接口函数DemoV3_D"
ClientHeight    =   9570
ClientLeft      =   45
ClientTop       =   435
ClientWidth     =   12255
LinkTopic       =   "Form1"
MaxButton       =   0   'False
MinButton       =   0   'False
ScaleHeight     =   9570
ScaleWidth      =   12255
ShowInTaskbar   =   0   'False
StartUpPosition =   2  'CenterScreen
Begin VB.Frame Frame3
Caption         =   "读写时钟信息"
Height          =   4095
Left            =   7950
TabIndex        =   47
Top             =   210
Width           =   3975
Begin VB.TextBox txtTime
Height          =   405
Left            =   1320
TabIndex        =   53
Top             =   930
Width           =   2205
End
Begin VB.TextBox txtCardID
Height          =   405
Left            =   1320
TabIndex        =   52
Top             =   450
Width           =   2205
End
Begin VB.TextBox txtXh
Height          =   345
Left            =   1320
TabIndex        =   51
Top             =   1410
Width           =   1455
End
Begin VB.TextBox Text12
ForeColor       =   &H000000FF&
Height          =   1095
Left            =   150
Locked          =   -1  'True
MultiLine       =   -1  'True
ScrollBars      =   2  'Vertical
TabIndex        =   50
Text            =   "Form1.frx":0000
Top             =   2010
Width           =   3975
End
Begin VB.CommandButton Command8
Caption         =   "读时钟"
Height          =   585
Left            =   960
TabIndex        =   49
Top             =   3240
Width           =   1155
End
Begin VB.CommandButton Command9
Caption         =   "写时钟"
Height          =   585
Left            =   2280
TabIndex        =   48
Top             =   3240
Width           =   1275
End
Begin VB.Label Label13
AutoSize        =   -1  'True
Caption         =   "时钟:"
Height          =   195
Left            =   600
TabIndex        =   56
Top             =   1050
Width           =   405
End
Begin VB.Label Label14
AutoSize        =   -1  'True
Caption         =   "作业流水号:"
Height          =   195
Left            =   150
TabIndex        =   55
Top             =   540
Width           =   945
End
Begin VB.Label Label15
Caption         =   "发卡序号"
Height          =   225
Left            =   330
TabIndex        =   54
Top             =   1500
Width           =   735
End
End
Begin VB.Frame Frame4
Caption         =   "读ID卡卡号"
Height          =   3075
Left            =   7950
TabIndex        =   44
Top             =   4680
Width           =   3975
Begin VB.TextBox txtIDCardNo
Height          =   375
Left            =   570
TabIndex        =   46
Top             =   720
Width           =   2895
End
Begin VB.CommandButton Command10
Caption         =   "读ID卡"
Height          =   585
Left            =   1590
TabIndex        =   45
Top             =   1380
Width           =   1155
End
End
Begin VB.TextBox txtLockAP
Height          =   375
Left            =   1320
TabIndex        =   36
Text            =   "0"
Top             =   810
Width           =   855
End
Begin VB.Frame Frame2
Caption         =   "已保存的门锁信息"
Height          =   3345
Left            =   3960
TabIndex        =   25
Top             =   210
Width           =   3855
Begin VB.CommandButton Command7
Caption         =   "打开文件"
Height          =   435
Left            =   2730
TabIndex        =   31
Top             =   2610
Width           =   975
End
Begin VB.ListBox List1
Height          =   1815
Left            =   210
TabIndex        =   30
Top             =   600
Width           =   3495
End
Begin VB.CommandButton Command6
Caption         =   "删除当前"
Height          =   435
Left            =   1590
TabIndex        =   29
Top             =   2610
Width           =   975
End
Begin VB.CommandButton Command5
Caption         =   "全部清空"
Height          =   435
Left            =   300
TabIndex        =   28
Top             =   2610
Width           =   1155
End
Begin VB.Label Label10
AutoSize        =   -1  'True
Caption         =   "房号:"
Height          =   195
Left            =   1440
TabIndex        =   27
Top             =   360
Width           =   405
End
Begin VB.Label Label9
AutoSize        =   -1  'True
Caption         =   "编号:"
Height          =   195
Left            =   210
TabIndex        =   26
Top             =   360
Width           =   405
End
End
Begin VB.CommandButton Command4
Caption         =   "保存编号及房号"
Height          =   435
Left            =   4170
TabIndex        =   24
Top             =   8940
Width           =   1635
End
Begin VB.TextBox Text10
Height          =   435
Left            =   1560
TabIndex        =   23
Top             =   4980
Width           =   2115
End
Begin VB.Frame 写卡数据
Caption         =   "写卡数据"
Height          =   3945
Left            =   120
TabIndex        =   11
Top             =   5520
Width           =   3615
Begin VB.TextBox txtCheckOutHour2
Height          =   435
Left            =   1320
TabIndex        =   60
Text            =   "12"
Top             =   3000
Width           =   2115
End
Begin VB.TextBox Text6
Height          =   435
Left            =   1350
TabIndex        =   59
Text            =   "1"
Top             =   2370
Width           =   2115
End
Begin VB.CheckBox chkOpenInner2
Caption         =   "是否开启反锁"
Height          =   225
Left            =   1800
TabIndex        =   57
Top             =   3600
Width           =   1815
End
Begin VB.TextBox Text4
Height          =   435
Left            =   1350
TabIndex        =   16
Text            =   "1"
Top             =   1320
Width           =   2115
End
Begin VB.TextBox Text5
Height          =   435
Left            =   1350
TabIndex        =   15
Text            =   "1"
Top             =   1845
Width           =   2115
End
Begin VB.CheckBox Check1
Caption         =   "是否挂失?"
Height          =   225
Left            =   240
TabIndex        =   14
Top             =   3600
Value           =   1  'Checked
Width           =   1425
End
Begin VB.TextBox Text8
Height          =   435
Left            =   1350
TabIndex        =   13
Top             =   795
Width           =   2115
End
Begin VB.TextBox Text9
Height          =   435
Left            =   1350
TabIndex        =   12
Top             =   270
Width           =   2115
End
Begin VB.Label lblCheckOutHour2
Caption         =   "退房钟点:"
Height          =   255
Left            =   240
TabIndex        =   58
Top             =   3120
Width           =   1095
End
Begin VB.Label Label2
AutoSize        =   -1  'True
Caption         =   "一小时内序号:"
Height          =   195
Left            =   30
TabIndex        =   21
Top             =   1334
Width           =   1125
End
Begin VB.Label Label4
AutoSize        =   -1  'True
Caption         =   "时间单位:"
Height          =   195
Left            =   390
TabIndex        =   20
Top             =   1851
Width           =   765
End
Begin VB.Label Label5
AutoSize        =   -1  'True
Caption         =   "时间长度:"
Height          =   195
Left            =   390
TabIndex        =   19
Top             =   2370
Width           =   765
End
Begin VB.Label Label6
AutoSize        =   -1  'True
Caption         =   "起始时间:"
Height          =   195
Left            =   390
TabIndex        =   18
Top             =   817
Width           =   765
End
Begin VB.Label Label7
AutoSize        =   -1  'True
Caption         =   "门锁编号:"
Height          =   195
Left            =   360
TabIndex        =   17
Top             =   300
Width           =   765
End
End
Begin VB.TextBox Text7
ForeColor       =   &H000000FF&
Height          =   4365
Left            =   3930
Locked          =   -1  'True
MultiLine       =   -1  'True
ScrollBars      =   2  'Vertical
TabIndex        =   5
Text            =   "Form1.frx":002E
Top             =   3960
Width           =   3975
End
Begin VB.CommandButton Command3
Caption         =   "关闭"
Height          =   435
Left            =   5880
TabIndex        =   4
Top             =   8970
Width           =   1635
End
Begin VB.CommandButton Command2
Caption         =   "写卡"
Height          =   435
Left            =   5880
TabIndex        =   3
Top             =   8400
Width           =   1635
End
Begin VB.CommandButton Command1
Caption         =   "读卡"
Height          =   435
Left            =   4170
TabIndex        =   2
Top             =   8400
Width           =   1635
End
Begin VB.TextBox Text1
Height          =   375
Left            =   1320
TabIndex        =   1
Text            =   "0"
Top             =   210
Width           =   855
End
Begin VB.Frame Frame1
Caption         =   "读卡数据"
Height          =   3495
Left            =   180
TabIndex        =   6
Top             =   1350
Width           =   3615
Begin VB.CheckBox chkOpenInner1
Caption         =   "是否开启反锁"
Height          =   195
Left            =   1440
TabIndex        =   63
Top             =   3240
Width           =   1935
End
Begin VB.TextBox txtCheckOutHour1
Height          =   435
Left            =   1380
TabIndex        =   62
Top             =   2640
Width           =   2115
End
Begin VB.TextBox txtEDT
Height          =   435
Left            =   1380
Locked          =   -1  'True
TabIndex        =   42
Top             =   2160
Width           =   2115
End
Begin VB.TextBox txtSDT
Height          =   435
Left            =   1380
Locked          =   -1  'True
TabIndex        =   40
Top             =   1680
Width           =   2115
End
Begin VB.TextBox Text11
Height          =   435
Left            =   1380
Locked          =   -1  'True
TabIndex        =   32
Top             =   1200
Width           =   2115
End
Begin VB.TextBox Text2
Height          =   435
Left            =   1380
Locked          =   -1  'True
TabIndex        =   8
Top             =   240
Width           =   2115
End
Begin VB.TextBox Text3
Height          =   435
Left            =   1380
Locked          =   -1  'True
TabIndex        =   7
Top             =   720
Width           =   2115
End
Begin VB.Label lblCheckOutHour1
Caption         =   "退房钟点:"
Height          =   255
Left            =   360
TabIndex        =   61
Top             =   2760
Width           =   975
End
Begin VB.Label Label21
AutoSize        =   -1  'True
Caption         =   "结束时间:"
Height          =   195
Left            =   390
TabIndex        =   43
Top             =   2250
Width           =   765
End
Begin VB.Label Label20
AutoSize        =   -1  'True
Caption         =   "起始时间:"
Height          =   195
Left            =   390
TabIndex        =   41
Top             =   1755
Width           =   765
End
Begin VB.Label Label11
AutoSize        =   -1  'True
Caption         =   "门锁编号2:"
Height          =   195
Left            =   300
TabIndex        =   33
Top             =   1260
Width           =   855
End
Begin VB.Label aaa
AutoSize        =   -1  'True
Caption         =   "门锁编号1:"
Height          =   195
Left            =   300
TabIndex        =   10
Top             =   270
Width           =   855
End
Begin VB.Label Label3
AutoSize        =   -1  'True
Caption         =   "作业流水号:"
Height          =   195
Left            =   210
TabIndex        =   9
Top             =   765
Width           =   945
End
End
Begin VB.Label Label19
AutoSize        =   -1  'True
Caption         =   "注:一般为0,具备二级销售商模式才生效"
Height          =   495
Left            =   2250
TabIndex        =   39
Top             =   780
Width           =   1665
WordWrap        =   -1  'True
End
Begin VB.Label Label18
AutoSize        =   -1  'True
Caption         =   "注:0=串口1,1=串口2,2=串口3,....."
Height          =   390
Left            =   2250
TabIndex        =   38
Top             =   300
Width           =   1575
WordWrap        =   -1  'True
End
Begin VB.Label Label17
AutoSize        =   -1  'True
Caption         =   "系统标识号(LockAP):"
Height          =   390
Left            =   180
TabIndex        =   37
Top             =   780
Width           =   1020
WordWrap        =   -1  'True
End
Begin VB.Label Label16
Caption         =   "Label16"
Height          =   30
Left            =   5370
TabIndex        =   35
Top             =   4740
Width           =   30
End
Begin VB.Label Label12
AutoSize        =   -1  'True
Caption         =   "注意:"
ForeColor       =   &H000000FF&
Height          =   195
Left            =   3960
TabIndex        =   34
Top             =   3750
Width           =   540
End
Begin VB.Label Label8
AutoSize        =   -1  'True
Caption         =   "输入房号名称:"
Height          =   195
Left            =   240
TabIndex        =   22
Top             =   5100
Width           =   1260
End
Begin VB.Label Label1
AutoSize        =   -1  'True
Caption         =   "串口号:"
Height          =   195
Left            =   450
TabIndex        =   0
Top             =   270
Width           =   720
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim nCom As Long
Dim MsTable(2 * 1024) As String
Dim nCount As Long
Dim pubBh As String
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Sub Command1_Click()
'On Error Resume Next
Dim nerr As Long
Dim bh1bit As String
Dim bh2bit As String
Dim bh3bit As String
Dim bh4bit As String
Dim strBh As String
nCom = Val(Text1.Text)
If nCom  255 Then
Text1.Text = 0
nCom = 0
End If
Call mif_closecom
'打开串口
nerr = mif_selecom(nCom, 9600)
Dim buf1 As String * 20
Dim buf2 As String * 20
Dim l_nLockAP As Long
Dim l_csSDT As String * 8
Dim l_csUnit As String * 8
Dim l_csTimes As String * 8
Dim l_csCheckOutHour As String * 8
Dim l_csOpenInner As String * 8
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "初始化串口错误!", vbOKOnly + vbInformation
Exit Sub
End If
l_nLockAP = Int(Val(txtLockAP.Text))
If l_nLockAP > 255 Then
l_nLockAP = 0
End If
'开始读数据
nerr = tem_readdoorcard_sdk(buf1, buf2, l_nLockAP)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
'开始读卡起始结束时间
nerr = tem_readdatetime13_sdk(l_csSDT, l_csUnit, l_csTimes, l_csCheckOutHour, l_csOpenInner, l_nLockAP)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
strBh = Mid(buf1, 1, 10)
Text2.Text = strBh
Text11.Text = strBh
Text9.Text = strBh
Text3.Text = buf2
txtCheckOutHour1.Text = l_csCheckOutHour
l_csOpenInner = Left(l_csOpenInner, 1)
chkOpenInner1.Value = Val(l_csOpenInner)
Dim l_csCOTime As String
Dim l_csSDT_All As String
Dim l_csEDT_All As String
l_csCOTime = "12"
l_csSDT_All = "20" & Mid(l_csSDT, 1, 2) & "-" & Mid(l_csSDT, 3, 2) & "-" & Mid(l_csSDT, 5, 2) & " " & Mid(l_csSDT, 7, 2)
l_csEDT_All = "20" & Mid(l_csSDT, 1, 2) & "-" & Mid(l_csSDT, 3, 2) & "-" & Mid(l_csSDT, 5, 2) & " " & l_csCOTime
l_csSDT_All = l_csSDT_All + ":00:00"
l_csEDT_All = l_csEDT_All + ":00:00"
Select Case Val(l_csUnit)
Case 0      '以时为单位
l_csEDT_All = CDate(l_csSDT_All) + Val(l_csTimes) / 24
Case 1      '以日为单位
l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes)
Case 2      '以月为单位
l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes) * 30
Case 3      '以年为单位
l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes) * 365
Case Else   '无效的时间单位
l_csEDT_All = "无效"
End Select
txtSDT.Text = l_csSDT_All
txtEDT.Text = l_csEDT_All
pubBh = Text2.Text
'关闭串口
Call mif_closecom
MsgBox "读卡成功!", vbOKOnly + vbInformation
End Sub
Private Sub Command10_Click()
On Error Resume Next
Dim nerr As Long
nCom = Val(Text1.Text)
If nCom  255 Then
Text1.Text = 0
nCom = 0
End If
Call mif_closecom
'打开串口
nerr = mif_selecom(nCom, 9600)
Dim buf1 As String * 10
'开始读ID卡卡号
nerr = tem_readidcard_sdk(buf1$)
If nerr <> 0 Then
'关闭串口
txtIDCardNo.Text = ""
Call mif_closecom
MsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
txtIDCardNo.Text = buf1
'关闭串口
Call mif_closecom
MsgBox "读卡成功!", vbOKOnly + vbInformation
End Sub
Private Sub Command2_Click()
On Error Resume Next
Dim nerr As Long
nCom = Val(Text1.Text)
If nCom  255 Then
Text1.Text = 0
nCom = 0
End If
Call mif_closecom
'打开串口
nerr = mif_selecom(nCom, 9600)
Dim buf1 As String * 4
Dim buf2 As String * 10
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "初始化串口错误!", vbOKOnly + vbInformation
Exit Sub
End If
Dim bh1bit As String
Dim bh2bit As String
Dim bh3bit As String
Dim bh4bit As String
Dim l_nLockAP As Long
Dim strBh As String
Dim bOpenInner As Boolean
Dim nCheckOutHour As Integer
nCheckOutHour = Val(txtCheckOutHour2.Text)
If nCheckOutHour  18 Then
MsgBox "退房钟点只能在11点到18点之间", vbOKOnly + vbInformation
Exit Sub
End If
strBh = Trim(Text9.Text)
If Len(strBh) <> 10 Then
Call mif_closecom
MsgBox "门锁编号的长度不足10位!", vbOKOnly + vbInformation
Exit Sub
End If
bh1bit = ChrB(Val("&H" & Mid(strBh, 1, 2)))
bh2bit = ChrB(Val("&H" & Mid(strBh, 3, 2)))
bh3bit = ChrB(Val("&H" & Mid(strBh, 5, 2)))
bh4bit = ChrB(Val("&H" & Mid(strBh, 7, 2)))
strBh = Text9.Text
buf1 = Text9.Text
buf2 = Text8.Text
l_nLockAP = Val(txtLockAP.Text)
If l_nLockAP > 255 Then
l_nLockAP = 0
End If
bOpenInner = chkOpenInner2.Value
'开始写数据
nerr = tem_writedoorcard13_sdk(strBh$, buf2$, Val(Text4.Text), Val(Text5.Text), Val(Text6.Text), Check1.Value, l_nLockAP, nCheckOutHour, bOpenInner)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "写卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
'关闭串口
Call mif_closecom
MsgBox "写卡成功!", vbOKOnly + vbInformation
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
If Text2.Text = "" Or Text10.Text = "" Then
MsgBox "无门锁编号或房号名称!", vbOKOnly + vbInformation
Exit Sub
End If
Dim curStr As String
Dim strCount As String
Dim i As Long
Dim curBh As String * 10
curBh = Text11.Text
curStr = curBh & vbTab & Text10.Text
For i = 0 To nCount - 1
If MsTable(i) = curStr Then
Exit Sub
End If
Next
nCount = nCount + 1
strCount = Str(nCount)
MsTable(nCount - 1) = curStr
Open App.Path & "\BhFh.txt" For Output As #1
Print #1, strCount
For i = 0 To nCount - 1
Print #1, MsTable(i)
Next
Close #1
Call OpenMsTabeFile
'    MsgBox "保存完成!", vbOKOnly + vbInformation
End Sub
Private Sub Command5_Click()
If MsgBox("确实全部清除吗?", vbYesNo + vbQuestion) = vbNo Then Exit Sub
CopyFile App.Path & "\bhfh.txt", App.Path & "\bhfh" + Format(Now, "mmddHHMMSS") + ".txt", False
Open App.Path & "\BhFh.txt" For Output As #1
Print #1, 0
Close #1
Call OpenMsTabeFile
End Sub
Private Sub Command6_Click()
Dim curStr As String
Dim strCount As String
Dim i As Long
If List1.ListIndex = -1 Then Exit Sub
If MsgBox("确实清除当前内容吗?", vbYesNo + vbQuestion) = vbNo Then Exit Sub
List1.RemoveItem List1.ListIndex
For i = 0 To List1.ListCount - 1
MsTable(i) = List1.List(i)
Next
nCount = List1.ListCount
strCount = Str(nCount)
Open App.Path & "\BhFh.txt" For Output As #1
Print #1, strCount
For i = 0 To nCount - 1
Print #1, MsTable(i)
Next
Close #1
Call OpenMsTabeFile
End Sub
Private Sub Command7_Click()
Dim id As Long
id = Shell("notepad.exe " + App.Path + "\BhFh.txt", vbNormalFocus)
End Sub
Private Sub Command8_Click()
'On Error Resume Next
Dim nerr As Long
Dim bh1bit As String
Dim bh2bit As String
Dim bh3bit As String
Dim bh4bit As String
Dim strFksj As String
Dim strTime As String
Dim buf1 As String * 10
Dim buf2 As String * 10
Dim l_nLockAP As Long
nCom = Val(Text1.Text)
If nCom  255 Then
Text1.Text = 0
nCom = 0
End If
Call mif_closecom
'打开串口
nerr = mif_selecom(nCom, 9600)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "初始化串口错误!", vbOKOnly + vbInformation
Exit Sub
End If
l_nLockAP = Int(Val(txtLockAP.Text))
If l_nLockAP > 255 Then
l_nLockAP = 0
End If
'开始读数据
nerr = tem_readtimercard_sdk(buf1, buf2, l_nLockAP)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
strFksj = Mid(buf1, 1, 10)
strTime = Mid(buf2, 1, 10)
txtCardID.Text = strFksj
txtTime.Text = strTime
txtXh.Text = Val("&H" + Right(strFksj, 2))
'关闭串口
Call mif_closecom
MsgBox "读卡成功!", vbOKOnly + vbInformation
End Sub
Private Sub Command9_Click()
'On Error Resume Next
Dim nerr As Long
Dim bh1bit As String
Dim bh2bit As String
Dim bh3bit As String
Dim bh4bit As String
Dim nxh As Long
Dim strFksj As String
Dim strTime As String
Dim l_nLockAP As Long
nCom = Val(Text1.Text)
If nCom  255 Then
Text1.Text = 0
nCom = 0
End If
Call mif_closecom
'打开串口
nerr = mif_selecom(nCom, 9600)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "初始化串口错误!", vbOKOnly + vbInformation
Exit Sub
End If
Dim buf1 As String
Dim buf2 As String
buf1 = Right(String(8, "0") + Left(Trim(txtCardID.Text), 8), 8)
buf2 = Right(String(10, "0") + Trim(txtTime.Text), 10)
nxh = Val(txtXh.Text)
l_nLockAP = Int(Val(txtLockAP.Text))
If l_nLockAP > 255 Then
l_nLockAP = 0
End If
'开始读数据
nerr = tem_writetimercard_sdk(buf1, nxh, buf2, l_nLockAP)
If nerr <> 0 Then
'关闭串口
Call mif_closecom
MsgBox "写卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformation
Exit Sub
End If
'关闭串口
Call mif_closecom
MsgBox "写卡成功!", vbOKOnly + vbInformation
End Sub
Private Sub Form_Load()
Dim curStr As String
Dim i As Long
Text8.Text = Right(Year(Date), 2) + Format(Month(Date), "00") + Format(Day(Date), "00") + Format(Hour(time), "00")
Call OpenMsTabeFile
End Sub
Private Sub OpenMsTabeFile()
Dim i As Long
Dim curStr As String
Dim curTotalStr As String
Dim strCount As String
List1.Clear
If Dir$(App.Path & "\BhFh.txt") <> "" Then
Open App.Path & "\BhFh.txt" For Input As #1
Input #1, strCount
nCount = strCount
For i = 0 To nCount - 1
Input #1, curStr
MsTable(i) = curStr
List1.AddItem curStr
Next
Close #1
End If
End Sub

开源地址

https://github.com/cyberwin

工程文件

Type=Exe
Form=Form1.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\Stdole2.tlb#OLE Automation
Module=Module1; Module1.bas
IconForm="Form1"
Startup="Form1"
HelpFile=""
Title="Project1"
ExeName32="RWCardDemo.exe"
Path32="..\接口文件"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="lc"
CompilationType=-1
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
[MS Transaction Server]
AutoRefresh=1

在东方仙盟的广袤世界里,练气期是修仙者踏上仙途的起始阶段,如同初入编程领域的新手,开始摸索着运用代码的 “灵气”,尝试构建各种奇妙的功能。这段 “感应门锁接口函数 DemoV3_D” 代码,就恰似练气期弟子手中的基础法术秘籍,虽不高深,却蕴含着实现门锁相关操作的关键奥秘。

界面搭建:构建修仙洞府的基石

整个程序界面如同练气期弟子精心搭建的洞府,各个组件便是洞府中的不同设施。Form1 作为主窗体,其 BorderStyle 设为 3,如同坚固的洞府边界,确保稳定性。Caption 显示 “感应门锁接口函数 DemoV3_D”,仿佛是洞府的铭牌,标明其用途。

  1. 框架与文本框:不同的 Frame 框架将界面划分为多个功能区域,就像洞府中的不同房间。例如,“读写时钟信息” 的 Frame3 区域,里面的 TextBox 控件,如 txtTimetxtCardID 等,宛如记录信息的玉简,等待用户输入或显示读取的数据。Label 控件则如同洞府中的指示牌,标注着每个区域和输入项的含义,如 Label13 显示 “时钟:”,引导用户操作。
  2. 按钮与列表框CommandButton 如同触发法术的开关,点击它们就能执行特定操作。比如 Command1 按钮,caption 为 “读卡”,点击后如同施展 “读卡法术”,实现从门锁读取数据的功能。ListBox 控件则像一个储物箱,List1 用于展示已保存的门锁信息,方便用户查看和管理。

代码逻辑:施展法术的奇妙过程

  1. 串口操作:程序中对串口的操作就像是练气期弟子操控灵气与外界沟通。通过 mif_selecom 函数选择串口,mif_closecom 函数关闭串口,如同打开和关闭与外界连接的通道。在 Command1_Click 等过程中,先获取用户输入的串口号 nCom,进行有效性检查后,调用 mif_selecom 打开串口,若初始化串口错误,便及时关闭串口并提示错误,就像法术施展失败后及时调整状态。
  2. 读卡操作:以 Command1_Click 为例,调用 tem_readdoorcard_sdk 函数读取门锁卡数据,调用 tem_readdatetime13_sdk 函数读取卡的起始结束时间等信息,这就像施展特定的 “读卡法术”,从门锁卡中获取关键信息。若读卡过程中出现错误,同样关闭串口并提示,确保操作的安全性。获取数据后,对数据进行处理和显示,如将读卡得到的起始时间、结束时间等进行格式化处理后显示在相应的 TextBox 中,仿佛将读取到的灵气信息进行整理和呈现。
  3. 写卡操作:在 Command2_Click 过程中,写卡操作如同施展 “写卡法术”。先对用户输入的信息进行有效性检查,如退房钟点是否在规定范围内、门锁编号长度是否正确等。然后调用 tem_writedoorcard13_sdk 函数将数据写入卡中。若写卡错误,关闭串口并提示,成功则提示写卡成功,如同法术施展成功后告知弟子。
  4. 文件操作Command4_ClickCommand5_Click 和 Command6_Click 等过程涉及文件操作,用于保存、清空和删除已保存的门锁信息,就像对洞府中的储物箱进行整理和管理。通过 Open 语句读写文件,将门锁编号和房号等信息保存到文件中,或者对文件内容进行清除和备份操作,确保数据的存储和管理有序进行。

总结:练气期编程的成长之路

这段代码对于刚接触编程的 “练气期” 开发者而言,是一次宝贵的实践历练。它展示了如何通过界面设计与代码逻辑实现与感应门锁的交互操作,从串口通信到数据读写,每一步都如同练气期弟子在修仙过程中逐步掌握基础法术。虽然代码功能相对基础,但为进一步深入编程领域,实现更复杂的功能奠定了坚实基础,如同练气期的扎实修炼为日后突破境界、掌握更强大法术做好准备。

阿雪技术观


让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量

Embrace open source and sharing, witness the miracle of technological progress, and enjoy the happy times of humanity! Let's actively join the wave of technology sharing. Not only as beneficiaries, but also as contributors. Whether sharing our own code, writing technical blogs, or participating in the maintenance and improvement of open source projects, every small action may become a huge force driving technological progrss. 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/918325.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

免费做图素材网站有哪些自己做发卡网站

文章目录1. 向管理表中装载数据2. 通过查询语句向表中插入数据3. 动态分区插入4. 从单个查询语句创建表并加载数据5. 导出数据学习自《Hive编程指南》 1. 向管理表中装载数据 hive (default)> load data local inpath "/home/hadoop/workspace/student.txt">…

PostgreSQL patroni 高可用 1:ectd 安装和配置

PostgreSQL patroni 高可用 1:ectd 安装和配置PostgreSQL patroni 高可用 1:ectd 安装PostgreSQL ptroni的高可用架构图如下所示,本文完成如下架构图中红色标记内的ectd分布式存储的安装和配置。图片来源于:https:…

实用指南:黄金价格小工具抖音快手微信小程序看广告流量主开源

实用指南:黄金价格小工具抖音快手微信小程序看广告流量主开源pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Con…

20250725_QQ_ezusb

流量分析, USB, pyshark, Base64, kamasutra, DASCTFTags:流量分析,USB,pyshark,Base64,kamasutra,DASCTF 0x00. 题目 附件路径:https://pan.baidu.com/s/1GyH7kitkMYywGC9YJeQLJA?pwd=Zmxh#list/path=/CTF附件 附件…

.netcore 程序启动时的核心类 - 指南

.netcore 程序启动时的核心类 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monac…

外贸系统软件有哪些手机优化大师官网

&#x1f308; 个人主页&#xff1a;谁在夜里看海. &#x1f525; 个人专栏&#xff1a;《C系列》《Linux系列》《算法系列》 ⛰️ 丢掉幻想&#xff0c;准备斗争 目录 引言 一、僵尸进程 1.子进程的创建与退出 2.进程表 3.僵尸状态产生 4.直观感受一下&#xff1a; 二、…

照片做视频的网站南通网站外包

文章目录 第五课&#xff1a;MindSpore自动并行1、学习总结&#xff1a;数据并行模型并行MindSpore算子级并行算子级并行示例 流水线并行GPipe和Micro batch1F1B流水线并行示例 内存优化重计算优化器并行 MindSpore分布式并行模式课程ppt及代码地址 2、学习心得&#xff1a;3、…

DailyPaper-2025-9-26

失踪人口回归,才识浅薄啥也不懂勿喷MMR1: Enhancing Multimodal Reasoning with Variance-Aware Sampling and Open Resources https://arxiv.org/pdf/2509.21268Variance-Aware Sampling and large-scale CoT data i…

实用指南:老题新解|素数对

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

人文领域的创新乏力:当价值内卷遇上元人文AI的破局之光

人文领域的创新乏力:当价值内卷遇上元人文AI的破局之光 当我们惊叹于科技领域的颠覆式创新时,却不得不面对一个尴尬的对比:人文领域的创新陷入了深度的乏力。 这里的"人文领域",指的是塑造我们社会形态、…

网站备份数据库做网站的网站犯法吗

试试了一下在 .NET中通过如下语句Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);就可以使页面的缓存失效&#xff0c;每次都需要获取新页面。 转载于:https://www.cnblogs.com/0000/archive/2009/11/11/1601036.html

查找公司信息的网站环保网站建设价格

注意&#xff0c;以下内容基于前面完整版的根文件系统&#xff0c;因此需要先完成前面的步骤。 1、明确sample文件夹的位置 海思SDK有很多sample&#xff0c;以方便开发人员的参阅。sample文件夹位于/package/mpp/目录下。 其中/package/mpp/sample/venc目录完成了视频的采集以…

网页制作门户网站案例气象网站建设需求方案

以下内容源于朱有鹏嵌入式课程的学习与整理&#xff0c;如有侵权请告知删除。 一、移植前的准备工作 1、搭建开发环境 &#xff08;1&#xff09;虚拟机运行着ubuntu14.04系统。 &#xff08;2&#xff09;X210开发板运行着linux内核镜像、QT4.8文件系统镜像。相关的镜像文件在…

自己公司设计一个网站电子商务网站建设与制作

Oracle 的导入实用程序 (Import utility) 允许从数据库提取数据&#xff0c;并且将数据写入操作系统文件。 imp 使用的基本格式&#xff1a; imp[username[/password[service]]] &#xff0c;以下例举 imp 常用用法。 1. 获取帮助 imp helpy 2. 导入一个完整数据库 imp sy…

SimCC: a Simple Coordinate Classification Perspective for Human Pose Estimation

[ECCV22] 基于坐标分类的关键点检测SimCC: a Simple Coordinate Classification Perspective for Human Pose Estimation SimCC(ECCV22):基于坐标分类计算关键点,即计算每个关键点在x轴、y轴上的概率。 代码仓库 注…

外贸看的英文网站鞍山最新消息

​FPGA高速接口有哪些学习途径&#xff0c;这里不得不提下我们宸极教育FPGA课程&#xff0c; FPGA课程5.0 版&#xff1a;Xilinx体系高速接口项目实操&#xff0c;全新升级&#xff0c;课程完全根据企业招聘要求&#xff0c;项目实操设置&#xff0c;适应目前市场的求职招聘要…

大连网站建设设计公司注册好了怎么做网站

一、前言 这篇文章主要介绍了CentOS 7.6环境下Nginx下载安装配置使用教程&#xff0c;学习nginx的朋友可以参考一下 二、下载 使用如下命令进行下载 wget http://nginx.org/download/nginx-1.23.3.tar.gz 三、安装nginx需要的环境库 项目首先我们需要安装gcc、gcc-c、zlib、…

北京融安特智能科技营销型网站wordpress archive

目录 对称加密算法 AES &#xff08;ECB模式&#xff09; AES(CBC 模式)。 非对称加密 对称加密算法 对称加密算法&#xff0c;是使用相同的密钥进行加密和解密。使用对称加密算法来加密双方的通信的话&#xff0c;双方需要先约定一个密钥&#xff0c;加密方才能加密&#…

全景网站制作教程现在还有做系统的网站吗

1.SELECT语句 从一个表或多个表中检索信息 2.检索单个列 输入&#xff1a; SELECT prod_name FROM Products; 输出&#xff1a; 没有过滤&#xff0c;也没有排序&#xff0c;输出数据顺序可能不同。 3.检索多个列 输入&#xff1a; SELECT prod_id, prod_name, prod_price F…