1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| Option Explicit
Option Base 0
Private Const CP_UTF8 = 65001
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long) As Long
Function ConvertUTF8(UTF8 As String) As String
Dim lLen As Long
Dim strOut As String
lLen = MultiByteToWideChar(CP_UTF8, 0, UTF8, Len(UTF8), 0, 0)
strOut = String(lLen * 2, 0)
MultiByteToWideChar CP_UTF8, 0, UTF8, Len(UTF8), strOut, lLen
ConvertUTF8 = StrConv(strOut, vbFromUnicode)
End Function
Private Sub ReadData()
'On Error GoTo errHandler
Dim lhandle As Long
Dim retStatus As EIDLIBCTRLLibCtl.retStatus
Dim MapColID As New EIDLIBCTRLLibCtl.MapCollection
Dim MapColAddress As New EIDLIBCTRLLibCtl.MapCollection
Dim MapColPicture As New EIDLIBCTRLLibCtl.MapCollection
Dim CertifCheck As New EIDLIBCTRLLibCtl.CertifCheck
Set retStatus = EIDlibCtrl.Init("", -1, -1, lhandle)
If (retStatus.GetGeneral = 0) Then
Set retStatus = EIDlibCtrl.GetID(MapColID, CertifCheck)
If (retStatus.GetGeneral = 0) Then
TextName.Text = ConvertUTF8(MapColID.GetValue("Name"))
TextGivennames.Text = ConvertUTF8(MapColID.GetValue("FirstName1")) + " " + ConvertUTF8(MapColID.GetValue("FirstName2"))
TextGivennames3.Text = ConvertUTF8(MapColID.GetValue("FirstName3"))
TextBirthPlace.Text = ConvertUTF8(MapColID.GetValue("BirthPlace"))
TextBirthDate.Text = MapColID.GetValue("BirthDate")
TextSex.Text = MapColID.GetValue("Gender")
TextTitle.Text = ConvertUTF8(MapColID.GetValue("NobilityTitle"))
TextNatNr.Text = MapColID.GetValue("NationalNumber")
TextIssMunicipality.Text = ConvertUTF8(MapColID.GetValue("IssuingMunicipality"))
TextChipNumber.Text = MapColID.GetValue("ChipNumber")
TextCardNumber.Text = MapColID.GetValue("CardNumber")
TextValidFrom.Text = MapColID.GetValue("BeginValidityDate")
TextValidUntil.Text = MapColID.GetValue("EndValidityDate")
DoEvents
Else
GoTo quit
' MsgBox "ID Failure : " & GetErrorString(retStatus)
End If
' Get Address
Set retStatus = EIDlibCtrl.GetAddress(MapColAddress, CertifCheck)
If (retStatus.GetGeneral = 0) Then
TextStreet.Text = ConvertUTF8(MapColAddress.GetValue("Street")) + " " + MapColAddress.GetValue("HouseNumber") + " " + MapColAddress.GetValue("BoxNumber")
TextZip.Text = MapColAddress.GetValue("ZIPCode")
TextMunicipality.Text = ConvertUTF8(MapColAddress.GetValue("Municipality"))
TextCountry = MapColAddress.GetValue("Country")
GoTo quit
Else
' MsgBox "Address Failure : " & GetErrorString(retStatus)
End If
End If
GoTo quit
errHandler:
' Close library
EIDlibCtrl.Exit
MsgBox Err.Description, vbExclamation, "Unknown Read Error"
quit:
' Close library
EIDlibCtrl.Exit
'Set lhandle = Nothing
Set retStatus = Nothing
Set MapColID = Nothing
Set MapColAddress = Nothing
Set MapColPicture = Nothing
Set CertifCheck = Nothing
Set retStatus = Nothing
Exit Sub
End Sub
Private Sub Timer1_Timer()
ReadData
End Sub |
Partager