www.pudn.com > 考勤管理系统源码(VB含串口接口程序).zip > smart.bas


Attribute VB_Name = "modSmart" 
 Declare Function PowerOn Lib "smartdll2.dll" () As Integer 
 Declare Function PowerOff Lib "smartdll2.dll" () As Integer 
 
 Declare Function OpenComm Lib "smartdll2.dll" (ByVal nPort As Integer) As Integer 
 Declare Function CloseComm Lib "smartdll2.dll" () As Integer 
 Declare Function GetState Lib "smartdll2.dll" (ByVal nPort As Integer) As Integer 
 
 Declare Function IC_ATR Lib "smartdll2.dll" (ByVal DataBuffer As String) As Integer 
 Declare Function IC_ReadMain Lib "smartdll2.dll" (ByVal Offset As Integer, ByVal Length As Integer, ByVal DataBuffer As String) As Integer 
 Declare Function IC_ReadProtect Lib "smartdll2.dll" (ByVal DataBuffer As String) As Integer 
 Declare Function IC_ReadSecurity Lib "smartdll2.dll" (ByVal DataBuffer As String) As Integer 
 Declare Function IC_ReadErrorCount Lib "smartdll2.dll" () As Integer 
 
 Declare Function IC_WriteMain Lib "smartdll2.dll" (ByVal Offset As Integer, ByVal Length As Integer, ByVal DataBuffer As String) As Integer 
 Declare Function IC_WriteProtect Lib "smartdll2.dll" (ByVal Offset As Integer, ByVal Length As Integer, ByVal DataBuffer As String) As Integer 
 Declare Function IC_UpdateSM Lib "smartdll2.dll" (ByVal Offset As Integer, ByVal Length As Integer, ByVal DataBuffer As String) As Integer 
 Declare Function IC_ChangePass Lib "smartdll2.dll" (ByVal PassWord As String) As Integer 
 Declare Function IC_PSCCheck Lib "smartdll2.dll" (ByVal DataBuffer As String) As Integer 
 Declare Function CardExist Lib "smartdll2.dll" () As Integer 
  
 Declare Function POS_IsReady Lib "smartdll2.dll" (ByVal nPosAddr As Byte) As Integer 
 Declare Function POS_GetTime Lib "smartdll2.dll" (ByVal nPosAddr As Byte, ByVal strTime As String) As Integer 
 Declare Function POS_SetTime Lib "smartdll2.dll" (ByVal nPosAddr As Byte, ByVal strTime As String) As Integer 
 Declare Function POS_GetNextFrame Lib "smartdll2.dll" (ByVal nPosAddr As Byte, ByVal strFrame As String) As Integer 
 Declare Function POS_GetFrameAgain Lib "smartdll2.dll" (ByVal nPosAddr As Byte, ByVal strFrame As String) As Integer 
 Declare Function POS_SetRecordCount Lib "smartdll2.dll" (ByVal nPosAddr As Byte, ByVal nRecordCount As Integer) As Integer 
  
 Declare Function ReadDot Lib "smartdll2.dll" (ByVal nCode As Integer, ByVal strDot As String) As Integer 
 Public Const dwOffset = &H40 
 Public Const dwLength = 13 
 Public Const dwNameOffset = &H80 
 Public Const dwNameLength = 96 
  
Function KeyFilter(KeyAscii As Integer, Optional isDigital As Boolean = False) As Integer 
     
    If isDigital Then 
        Select Case KeyAscii 
           Case Asc("0") To Asc("9"), Asc("a") To Asc("f"), Asc("A") To Asc("F"), vbKeyBack, vbKeyLButton, vbKeyRButton, vbKeyTab, vbKeyReturn 
                KeyFilter = KeyAscii 
                Exit Function 
           Case Else 
             KeyFilter = 7 'beep 
        End Select 
    Else 
        Select Case KeyAscii 
           Case Asc("0") To Asc("9"), Asc("a") To Asc("z"), Asc("A") To Asc("Z"), vbKeyBack, vbKeyLButton, vbKeyRButton, vbKeyTab, vbKeyReturn 
                KeyFilter = KeyAscii 
                Exit Function 
           Case Else 
             KeyFilter = 7 'beep 
        End Select 
    End If 
End Function 
Function CharToNum(inChar As String) As Byte 
    Select Case UCase(inChar) 
        Case "0" To "9": CharToNum = CByte(inChar) 
        Case "A" To "F": CharToNum = Asc(UCase(inChar)) - 55 
        Case Else:       CharToNum = 0 
    End Select 
End Function