|
Question : Late bindingan ActiveX component
|
|
Hi experts,
In Belgium everybody gets an ID card with a chip on it containing basic personal information (name, adress etc.) You can buy a very cheap reader that comes with the necessary ActiveX components to link it to your application. I managed to integrate this into my Access 2003 application and it works just fine.
However, if I run my (compiled) application on a machine where the dll's were not installed, it crashes without mercy. Not all my customers have a reader, so that's no good. I looked into late binding, but that throws me an "ActiveX component can't create object" error. So my question is, is it possible to do late binding on an ActiveX component?
This is the working code I would like to convert to late binding. ---------------------------- Sub TestEID() Dim EIDlib1 As New EIDLIBCTRLLib.EIDlib Dim lhandle As Long
Dim RetStatus As New EIDLIBCTRLLib.RetStatus Dim MapColPicture As New EIDLIBCTRLLib.MapCollection Dim MapColID As New EIDLIBCTRLLib.MapCollection Dim MapColAddress As New EIDLIBCTRLLib.MapCollection Dim CertifCheck As New EIDLIBCTRLLib.CertifCheck
Dim strName As String Dim strFirstName1 As String Dim strBirthPlace As String Dim strBirthDate As String Dim strGender As String Dim strNationality As String Dim strNationalNumber As String
Dim strStreet As String Dim strZipcode As String Dim strMunicipality As String
Dim Pasfoto_Temp As Variant
Set RetStatus = EIDlib1.Init("", 0, 0, lhandle)
Set RetStatus = EIDlib1.GetID(MapColID, CertifCheck)
strName = MapColID.GetValue("Name") strFirstName1 = MapColID.GetValue("FirstName1") strBirthDate = MapColID.GetValue("BirthDate") strBirthPlace = MapColID.GetValue("BirthPlace") strGender = MapColID.GetValue("Gender") strNationality = MapColID.GetValue("Nationality") strNationalNumber = MapColID.GetValue("NationalNumber")
Set RetStatus = EIDlib1.GetAddress(MapColAddress, CertifCheck)
strStreet = MapColAddress.GetValue("Street") strZipcode = MapColAddress.GetValue("ZIPCode") strMunicipality = MapColAddress.GetValue("Municipality")
Set RetStatus = EIDlib1.GetPicture(MapColPicture, CertifCheck) Pasfoto_Temp = MapColPicture.GetValue("Picture")
Set RetStatus = EIDlib1.Exit
MsgBox strName & ", " & strFirstName1 & vbCrLf & _ strStreet & vbCrLf & _ strZipcode & " " & strMunicipality & vbCrLf, vbOKOnly End Sub ---------------------------------
thanks, Michiel
|
|
Answer : Late bindingan ActiveX component
|
|
Sorry but I use it in Access all the time! From the VBA help...
Understanding Conditional Compilation
You can use conditional compilation to run blocks of code selectively, for example, debugging statements comparing the speed of different approaches to the same programming task, or localizing an application for different languages.
You declare a conditional compiler constant in code with the #Const directive, and you denote blocks of code to be conditionally compiled with the #If...Then...#Else directive. The following example runs debug code or production code, based on the value of the conDebug variable.
' Declare public compilation constant in Declarations section. #Const conDebug = 1
Sub SelectiveExecution() #If conDebug = 1 Then . ' Run code with debugging statements. . . #Else . ' Run normal code. . . #End If End Sub
|
|
|
|