当前位置: 首页 > news >正文

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

文件列表

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 LongPublic Declare Function mif_selecard Lib "LCRFRW_SDK.dll" (ByVal ncardtype As Long) As LongPublic Declare Function mif_closecom Lib "LCRFRW_SDK.dll" () As LongPublic 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 LongPublic 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 LongPublic Declare Function tem_readidcard_sdk Lib "LCRFRW_SDK.dll" (ByVal idbuff$) As LongPublic 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 DialogCaption         =   "感应门锁接口函数DemoV3_D"ClientHeight    =   9570ClientLeft      =   45ClientTop       =   435ClientWidth     =   12255LinkTopic       =   "Form1"MaxButton       =   0   'FalseMinButton       =   0   'FalseScaleHeight     =   9570ScaleWidth      =   12255ShowInTaskbar   =   0   'FalseStartUpPosition =   2  'CenterScreenBegin VB.Frame Frame3 Caption         =   "读写时钟信息"Height          =   4095Left            =   7950TabIndex        =   47Top             =   210Width           =   3975Begin VB.TextBox txtTime Height          =   405Left            =   1320TabIndex        =   53Top             =   930Width           =   2205EndBegin VB.TextBox txtCardID Height          =   405Left            =   1320TabIndex        =   52Top             =   450Width           =   2205EndBegin VB.TextBox txtXh Height          =   345Left            =   1320TabIndex        =   51Top             =   1410Width           =   1455EndBegin VB.TextBox Text12 ForeColor       =   &H000000FF&Height          =   1095Left            =   150Locked          =   -1  'TrueMultiLine       =   -1  'TrueScrollBars      =   2  'VerticalTabIndex        =   50Text            =   "Form1.frx":0000Top             =   2010Width           =   3975EndBegin VB.CommandButton Command8 Caption         =   "读时钟"Height          =   585Left            =   960TabIndex        =   49Top             =   3240Width           =   1155EndBegin VB.CommandButton Command9 Caption         =   "写时钟"Height          =   585Left            =   2280TabIndex        =   48Top             =   3240Width           =   1275EndBegin VB.Label Label13 AutoSize        =   -1  'TrueCaption         =   "时钟:"Height          =   195Left            =   600TabIndex        =   56Top             =   1050Width           =   405EndBegin VB.Label Label14 AutoSize        =   -1  'TrueCaption         =   "作业流水号:"Height          =   195Left            =   150TabIndex        =   55Top             =   540Width           =   945EndBegin VB.Label Label15 Caption         =   "发卡序号"Height          =   225Left            =   330TabIndex        =   54Top             =   1500Width           =   735EndEndBegin VB.Frame Frame4 Caption         =   "读ID卡卡号"Height          =   3075Left            =   7950TabIndex        =   44Top             =   4680Width           =   3975Begin VB.TextBox txtIDCardNo Height          =   375Left            =   570TabIndex        =   46Top             =   720Width           =   2895EndBegin VB.CommandButton Command10 Caption         =   "读ID卡"Height          =   585Left            =   1590TabIndex        =   45Top             =   1380Width           =   1155EndEndBegin VB.TextBox txtLockAP Height          =   375Left            =   1320TabIndex        =   36Text            =   "0"Top             =   810Width           =   855EndBegin VB.Frame Frame2 Caption         =   "已保存的门锁信息"Height          =   3345Left            =   3960TabIndex        =   25Top             =   210Width           =   3855Begin VB.CommandButton Command7 Caption         =   "打开文件"Height          =   435Left            =   2730TabIndex        =   31Top             =   2610Width           =   975EndBegin VB.ListBox List1 Height          =   1815Left            =   210TabIndex        =   30Top             =   600Width           =   3495EndBegin VB.CommandButton Command6 Caption         =   "删除当前"Height          =   435Left            =   1590TabIndex        =   29Top             =   2610Width           =   975EndBegin VB.CommandButton Command5 Caption         =   "全部清空"Height          =   435Left            =   300TabIndex        =   28Top             =   2610Width           =   1155EndBegin VB.Label Label10 AutoSize        =   -1  'TrueCaption         =   "房号:"Height          =   195Left            =   1440TabIndex        =   27Top             =   360Width           =   405EndBegin VB.Label Label9 AutoSize        =   -1  'TrueCaption         =   "编号:"Height          =   195Left            =   210TabIndex        =   26Top             =   360Width           =   405EndEndBegin VB.CommandButton Command4 Caption         =   "保存编号及房号"Height          =   435Left            =   4170TabIndex        =   24Top             =   8940Width           =   1635EndBegin VB.TextBox Text10 Height          =   435Left            =   1560TabIndex        =   23Top             =   4980Width           =   2115EndBegin VB.Frame 写卡数据 Caption         =   "写卡数据"Height          =   3945Left            =   120TabIndex        =   11Top             =   5520Width           =   3615Begin VB.TextBox txtCheckOutHour2 Height          =   435Left            =   1320TabIndex        =   60Text            =   "12"Top             =   3000Width           =   2115EndBegin VB.TextBox Text6 Height          =   435Left            =   1350TabIndex        =   59Text            =   "1"Top             =   2370Width           =   2115EndBegin VB.CheckBox chkOpenInner2 Caption         =   "是否开启反锁"Height          =   225Left            =   1800TabIndex        =   57Top             =   3600Width           =   1815EndBegin VB.TextBox Text4 Height          =   435Left            =   1350TabIndex        =   16Text            =   "1"Top             =   1320Width           =   2115EndBegin VB.TextBox Text5 Height          =   435Left            =   1350TabIndex        =   15Text            =   "1"Top             =   1845Width           =   2115EndBegin VB.CheckBox Check1 Caption         =   "是否挂失?"Height          =   225Left            =   240TabIndex        =   14Top             =   3600Value           =   1  'CheckedWidth           =   1425EndBegin VB.TextBox Text8 Height          =   435Left            =   1350TabIndex        =   13Top             =   795Width           =   2115EndBegin VB.TextBox Text9 Height          =   435Left            =   1350TabIndex        =   12Top             =   270Width           =   2115EndBegin VB.Label lblCheckOutHour2 Caption         =   "退房钟点:"Height          =   255Left            =   240TabIndex        =   58Top             =   3120Width           =   1095EndBegin VB.Label Label2 AutoSize        =   -1  'TrueCaption         =   "一小时内序号:"Height          =   195Left            =   30TabIndex        =   21Top             =   1334Width           =   1125EndBegin VB.Label Label4 AutoSize        =   -1  'TrueCaption         =   "时间单位:"Height          =   195Left            =   390TabIndex        =   20Top             =   1851Width           =   765EndBegin VB.Label Label5 AutoSize        =   -1  'TrueCaption         =   "时间长度:"Height          =   195Left            =   390TabIndex        =   19Top             =   2370Width           =   765EndBegin VB.Label Label6 AutoSize        =   -1  'TrueCaption         =   "起始时间:"Height          =   195Left            =   390TabIndex        =   18Top             =   817Width           =   765EndBegin VB.Label Label7 AutoSize        =   -1  'TrueCaption         =   "门锁编号:"Height          =   195Left            =   360TabIndex        =   17Top             =   300Width           =   765EndEndBegin VB.TextBox Text7 ForeColor       =   &H000000FF&Height          =   4365Left            =   3930Locked          =   -1  'TrueMultiLine       =   -1  'TrueScrollBars      =   2  'VerticalTabIndex        =   5Text            =   "Form1.frx":002ETop             =   3960Width           =   3975EndBegin VB.CommandButton Command3 Caption         =   "关闭"Height          =   435Left            =   5880TabIndex        =   4Top             =   8970Width           =   1635EndBegin VB.CommandButton Command2 Caption         =   "写卡"Height          =   435Left            =   5880TabIndex        =   3Top             =   8400Width           =   1635EndBegin VB.CommandButton Command1 Caption         =   "读卡"Height          =   435Left            =   4170TabIndex        =   2Top             =   8400Width           =   1635EndBegin VB.TextBox Text1 Height          =   375Left            =   1320TabIndex        =   1Text            =   "0"Top             =   210Width           =   855EndBegin VB.Frame Frame1 Caption         =   "读卡数据"Height          =   3495Left            =   180TabIndex        =   6Top             =   1350Width           =   3615Begin VB.CheckBox chkOpenInner1 Caption         =   "是否开启反锁"Height          =   195Left            =   1440TabIndex        =   63Top             =   3240Width           =   1935EndBegin VB.TextBox txtCheckOutHour1 Height          =   435Left            =   1380TabIndex        =   62Top             =   2640Width           =   2115EndBegin VB.TextBox txtEDT Height          =   435Left            =   1380Locked          =   -1  'TrueTabIndex        =   42Top             =   2160Width           =   2115EndBegin VB.TextBox txtSDT Height          =   435Left            =   1380Locked          =   -1  'TrueTabIndex        =   40Top             =   1680Width           =   2115EndBegin VB.TextBox Text11 Height          =   435Left            =   1380Locked          =   -1  'TrueTabIndex        =   32Top             =   1200Width           =   2115EndBegin VB.TextBox Text2 Height          =   435Left            =   1380Locked          =   -1  'TrueTabIndex        =   8Top             =   240Width           =   2115EndBegin VB.TextBox Text3 Height          =   435Left            =   1380Locked          =   -1  'TrueTabIndex        =   7Top             =   720Width           =   2115EndBegin VB.Label lblCheckOutHour1 Caption         =   "退房钟点:"Height          =   255Left            =   360TabIndex        =   61Top             =   2760Width           =   975EndBegin VB.Label Label21 AutoSize        =   -1  'TrueCaption         =   "结束时间:"Height          =   195Left            =   390TabIndex        =   43Top             =   2250Width           =   765EndBegin VB.Label Label20 AutoSize        =   -1  'TrueCaption         =   "起始时间:"Height          =   195Left            =   390TabIndex        =   41Top             =   1755Width           =   765EndBegin VB.Label Label11 AutoSize        =   -1  'TrueCaption         =   "门锁编号2:"Height          =   195Left            =   300TabIndex        =   33Top             =   1260Width           =   855EndBegin VB.Label aaa AutoSize        =   -1  'TrueCaption         =   "门锁编号1:"Height          =   195Left            =   300TabIndex        =   10Top             =   270Width           =   855EndBegin VB.Label Label3 AutoSize        =   -1  'TrueCaption         =   "作业流水号:"Height          =   195Left            =   210TabIndex        =   9Top             =   765Width           =   945EndEndBegin VB.Label Label19 AutoSize        =   -1  'TrueCaption         =   "注:一般为0,具备二级销售商模式才生效"Height          =   495Left            =   2250TabIndex        =   39Top             =   780Width           =   1665WordWrap        =   -1  'TrueEndBegin VB.Label Label18 AutoSize        =   -1  'TrueCaption         =   "注:0=串口1,1=串口2,2=串口3,....."Height          =   390Left            =   2250TabIndex        =   38Top             =   300Width           =   1575WordWrap        =   -1  'TrueEndBegin VB.Label Label17 AutoSize        =   -1  'TrueCaption         =   "系统标识号(LockAP):"Height          =   390Left            =   180TabIndex        =   37Top             =   780Width           =   1020WordWrap        =   -1  'TrueEndBegin VB.Label Label16 Caption         =   "Label16"Height          =   30Left            =   5370TabIndex        =   35Top             =   4740Width           =   30EndBegin VB.Label Label12 AutoSize        =   -1  'TrueCaption         =   "注意:"ForeColor       =   &H000000FF&Height          =   195Left            =   3960TabIndex        =   34Top             =   3750Width           =   540EndBegin VB.Label Label8 AutoSize        =   -1  'TrueCaption         =   "输入房号名称:"Height          =   195Left            =   240TabIndex        =   22Top             =   5100Width           =   1260EndBegin VB.Label Label1 AutoSize        =   -1  'TrueCaption         =   "串口号:"Height          =   195Left            =   450TabIndex        =   0Top             =   270Width           =   720End
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 LongPrivate 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 StringDim strBh As StringnCom = Val(Text1.Text)
If nCom < 0 Or nCom > 255 ThenText1.Text = 0nCom = 0
End IfCall mif_closecom'打开串口
nerr = mif_selecom(nCom, 9600)Dim buf1 As String * 20
Dim buf2 As String * 20
Dim l_nLockAP As LongDim 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 * 8If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "初始化串口错误!", vbOKOnly + vbInformationExit Sub
End Ifl_nLockAP = Int(Val(txtLockAP.Text))If l_nLockAP > 255 Thenl_nLockAP = 0
End If'开始读数据
nerr = tem_readdoorcard_sdk(buf1, buf2, l_nLockAP)
If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit 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_closecomMsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit Sub
End IfstrBh = 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 StringDim l_csSDT_All As String
Dim l_csEDT_All As Stringl_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_csCOTimel_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) / 24Case 1      '以日为单位l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes)Case 2      '以月为单位l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes) * 30Case 3      '以年为单位l_csEDT_All = CDate(l_csEDT_All) + Val(l_csTimes) * 365Case Else   '无效的时间单位l_csEDT_All = "无效"End SelecttxtSDT.Text = l_csSDT_AlltxtEDT.Text = l_csEDT_AllpubBh = Text2.Text'关闭串口
Call mif_closecom
MsgBox "读卡成功!", vbOKOnly + vbInformationEnd SubPrivate Sub Command10_Click()On Error Resume NextDim nerr As LongnCom = Val(Text1.Text)If nCom < 0 Or nCom > 255 ThenText1.Text = 0nCom = 0End IfCall 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_closecomMsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit SubEnd IftxtIDCardNo.Text = buf1'关闭串口Call mif_closecomMsgBox "读卡成功!", vbOKOnly + vbInformationEnd SubPrivate Sub Command2_Click()
On Error Resume Next
Dim nerr As LongnCom = Val(Text1.Text)
If nCom < 0 Or nCom > 255 ThenText1.Text = 0nCom = 0
End IfCall mif_closecom'打开串口
nerr = mif_selecom(nCom, 9600)Dim buf1 As String * 4
Dim buf2 As String * 10
If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "初始化串口错误!", vbOKOnly + vbInformationExit Sub
End IfDim 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 < 11 Or nCheckOutHour > 18 ThenMsgBox "退房钟点只能在11点到18点之间", vbOKOnly + vbInformationExit Sub
End IfstrBh = Trim(Text9.Text)If Len(strBh) <> 10 ThenCall mif_closecomMsgBox "门锁编号的长度不足10位!", vbOKOnly + vbInformationExit Sub
End Ifbh1bit = 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.Textbuf1 = Text9.Text
buf2 = Text8.Textl_nLockAP = Val(txtLockAP.Text)If l_nLockAP > 255 Thenl_nLockAP = 0
End IfbOpenInner = 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_closecomMsgBox "写卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit Sub
End If'关闭串口
Call mif_closecom
MsgBox "写卡成功!", vbOKOnly + vbInformation
End SubPrivate Sub Command3_Click()End
End SubPrivate Sub Command4_Click()If Text2.Text = "" Or Text10.Text = "" ThenMsgBox "无门锁编号或房号名称!", vbOKOnly + vbInformationExit SubEnd IfDim curStr As StringDim strCount As StringDim i As LongDim curBh As String * 10curBh = Text11.TextcurStr = curBh & vbTab & Text10.TextFor i = 0 To nCount - 1If MsTable(i) = curStr ThenExit SubEnd IfNextnCount = nCount + 1strCount = Str(nCount)MsTable(nCount - 1) = curStrOpen App.Path & "\BhFh.txt" For Output As #1Print #1, strCountFor i = 0 To nCount - 1Print #1, MsTable(i)NextClose #1Call OpenMsTabeFile'    MsgBox "保存完成!", vbOKOnly + vbInformationEnd SubPrivate Sub Command5_Click()If MsgBox("确实全部清除吗?", vbYesNo + vbQuestion) = vbNo Then Exit SubCopyFile App.Path & "\bhfh.txt", App.Path & "\bhfh" + Format(Now, "mmddHHMMSS") + ".txt", FalseOpen App.Path & "\BhFh.txt" For Output As #1Print #1, 0Close #1Call OpenMsTabeFile
End SubPrivate Sub Command6_Click()Dim curStr As StringDim strCount As StringDim i As LongIf List1.ListIndex = -1 Then Exit SubIf MsgBox("确实清除当前内容吗?", vbYesNo + vbQuestion) = vbNo Then Exit SubList1.RemoveItem List1.ListIndexFor i = 0 To List1.ListCount - 1MsTable(i) = List1.List(i)NextnCount = List1.ListCountstrCount = Str(nCount)Open App.Path & "\BhFh.txt" For Output As #1Print #1, strCountFor i = 0 To nCount - 1Print #1, MsTable(i)NextClose #1Call OpenMsTabeFile
End SubPrivate Sub Command7_Click()Dim id As Longid = Shell("notepad.exe " + App.Path + "\BhFh.txt", vbNormalFocus)
End SubPrivate Sub Command8_Click()'On Error Resume NextDim nerr As LongDim bh1bit As StringDim bh2bit As StringDim bh3bit As StringDim bh4bit As StringDim strFksj As StringDim strTime As StringDim buf1 As String * 10Dim buf2 As String * 10Dim l_nLockAP As LongnCom = Val(Text1.Text)If nCom < 0 Or nCom > 255 ThenText1.Text = 0nCom = 0End IfCall mif_closecom'打开串口nerr = mif_selecom(nCom, 9600)If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "初始化串口错误!", vbOKOnly + vbInformationExit SubEnd Ifl_nLockAP = Int(Val(txtLockAP.Text))If l_nLockAP > 255 Thenl_nLockAP = 0End If'开始读数据nerr = tem_readtimercard_sdk(buf1, buf2, l_nLockAP)If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "读卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit SubEnd IfstrFksj = Mid(buf1, 1, 10)strTime = Mid(buf2, 1, 10)txtCardID.Text = strFksjtxtTime.Text = strTimetxtXh.Text = Val("&H" + Right(strFksj, 2))'关闭串口Call mif_closecomMsgBox "读卡成功!", vbOKOnly + vbInformationEnd SubPrivate Sub Command9_Click()
'On Error Resume NextDim nerr As LongDim bh1bit As StringDim bh2bit As StringDim bh3bit As StringDim bh4bit As StringDim nxh As LongDim strFksj As StringDim strTime As StringDim l_nLockAP As LongnCom = Val(Text1.Text)If nCom < 0 Or nCom > 255 ThenText1.Text = 0nCom = 0End IfCall mif_closecom'打开串口nerr = mif_selecom(nCom, 9600)If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "初始化串口错误!", vbOKOnly + vbInformationExit SubEnd IfDim buf1 As StringDim buf2 As Stringbuf1 = 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 Thenl_nLockAP = 0End If'开始读数据nerr = tem_writetimercard_sdk(buf1, nxh, buf2, l_nLockAP)If nerr <> 0 Then'关闭串口Call mif_closecomMsgBox "写卡错误!(" & Str(nerr) & ")", vbOKOnly + vbInformationExit SubEnd If'关闭串口Call mif_closecomMsgBox "写卡成功!", vbOKOnly + vbInformation
End SubPrivate Sub Form_Load()Dim curStr As StringDim i As LongText8.Text = Right(Year(Date), 2) + Format(Month(Date), "00") + Format(Day(Date), "00") + Format(Hour(time), "00")Call OpenMsTabeFileEnd SubPrivate Sub OpenMsTabeFile()Dim i As LongDim curStr As StringDim curTotalStr As StringDim strCount As StringList1.ClearIf Dir$(App.Path & "\BhFh.txt") <> "" ThenOpen App.Path & "\BhFh.txt" For Input As #1Input #1, strCountnCount = strCountFor i = 0 To nCount - 1Input #1, curStrMsTable(i) = curStrList1.AddItem curStrNextClose #1End 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.dtcms.com/a/403819.html

相关文章:

  • 一个主机一个域名做网站商城网站建设运营方案
  • 鸿蒙NEXT应用权限申请全攻略:从配置到授权实战
  • wordpress 文章的形式简述搜索引擎优化的方法
  • 有哪些网站可以做ps挣钱网做网站
  • 个人信息网站建设的心得体会长椿街网站建设
  • MacOS报错“zsh: command not found: brew”【已解决】
  • 网站设计策划书模板wordpress程序上传
  • flash attention利用GPU众核加速注意力计算
  • 晶泰科技与百诚医药签订合作意向书,共同推进AI新药研发合作
  • 漫谈《数字图像处理》之特征提取技术通用分类
  • 如何用php做电商网站wordpress优惠劵
  • [公众号阅读](中国科学院网络中心孙德刚团队)基于语义图学习的恶意域名检测技术
  • 创新的做网站软文写手兼职
  • UE5 小知识点 —— 08 - 摄像机小问题
  • 《UE5_C++多人TPS完整教程》学习笔记59 ——《P60 投射物武器(Projectile Weapons)》
  • 高新快速建设网站电话wordpress玻璃透主题
  • Splunk DB connect 增量查询数据
  • odoo-068 pdf 批量转 img,及 os、 PyMuPDF
  • Leetcode 394. 字符串解码 栈
  • 安康网站建设公司网站建立初步
  • 建设银行网站 购买外汇国美电器如何进行网站的建设与维护
  • MCU的取指周期与等待周期以及指令预取与缓存机制
  • ESP32 IDF 分区表
  • 房地产网站怎么推广贵阳网站建设方案推广
  • 开源 | 充电桩 运维 管理平台(IoT+运维工单平台)功能清单 - 慧知开源充电桩平台
  • 写给初学网站开发们的一封信宁波微信开发
  • 百度代理公司怎么样seo联盟
  • 在指定的进程中查找特定DLL模块
  • 关于页表过长的一些思考
  • 添加网站备案号链接建设网站应该注意的地方