Hello!
I want to get some parameters directly from windows as per file described library below into VBA in order for me to convert it into Json format:
The fiscal code library is used for generate Fiscal code that should be printed on Invoices. It is a DLL (dynamic link library) that can be install in windows IDE and import by programming language C/C++/C#. There is only one method in this library as follows:
If I was to use C++ , then the function should be as below to get the parameters:
I have tried to convert the above code to VBA so that the above listed parameters can be called from MS Access project and below is my replica function of C++ to VBA
Requirements
I want to include all parameters (TPIN, code, number, date, terminalID, amount, fiscalCode, int keyLen) in the VBA Json code below so that I make one string and then send to the internet to the server. How do I call the above parameters in the VBA Json format below? Here are the parameters (TPIN, code, number, date, terminalID, amount, fiscalCode, int keyLen)
Below is my VBA Json converter
If you check below I used also a similar code to get the computer serial number to be part of my Json code and its working ok see below the code and the final screen shoot results
I want to get some parameters directly from windows as per file described library below into VBA in order for me to convert it into Json format:
The fiscal code library is used for generate Fiscal code that should be printed on Invoices. It is a DLL (dynamic link library) that can be install in windows IDE and import by programming language C/C++/C#. There is only one method in this library as follows:
If I was to use C++ , then the function should be as below to get the parameters:
C++:
IntGetFiscalCode(c har *TPIN, char *code, char *number, char *date, char *terminalID, char * amount, char *fiscalCode, char *int keyLen);
I have tried to convert the above code to VBA so that the above listed parameters can be called from MS Access project and below is my replica function of C++ to VBA
Code:
Public Function IntGetFiscalCode(ByVal TPIN As String, ByVal code As String, ByVal number As String, ByVal date As String, ByVal terminalID As String, ByVal amount As String, ByVal fiscalCode As String, ByVal intKeyLen As Integer) As Integer
End Function
Requirements
I want to include all parameters (TPIN, code, number, date, terminalID, amount, fiscalCode, int keyLen) in the VBA Json code below so that I make one string and then send to the internet to the server. How do I call the above parameters in the VBA Json format below? Here are the parameters (TPIN, code, number, date, terminalID, amount, fiscalCode, int keyLen)
Below is my VBA Json converter
Code:
'Arranging parameters in Json format
Private Sub CmdNewJsons_Click()
Dim Businessdata As New Dictionary
Dim Main As New Dictionary
Dim Content As New Dictionary
Dim Report As New Dictionary
Set Businessdata = New Dictionary
Set Report = New Dictionary
Set Main = New Dictionary
Set Content = New Dictionary
With Content
.Add "Message", Businessdata
Businessdata.Add "Body", Main
Main.Add "data", Report
Report.Add "device", "531030026147"
Report.Add "serial", "00000"
Report.Add "bus_id", "Invoice - App - A"
Report.Add "Sign", "YYY"
Report.Add "key", "KKK"
Report.Add "ComputerKey", GetPCSerialNumber()
End With
Dim member As Variant
For Each member In Content
Next
MsgBox JsonConverter.ConvertToJson(Content, Whitespace:=3), vbOKOnly, "Audited by Chris Hankwembo"
End Sub
If you check below I used also a similar code to get the computer serial number to be part of my Json code and its working ok see below the code and the final screen shoot results
Code:
'Getting the computer serial number
Public Function GetPCSerialNumber()
Dim objWMIService As Object
Dim colItems As Variant
Dim objItem
Dim strMsg As String
Set objWMIService = GetObject("winmgmts://./root/cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS Where PrimaryBIOS = true", , 48)
For Each objItem In colItems
strMsg = objItem.SerialNumber
Next
GetPCSerialNumber = strMsg
End Function
Last edited: