Private Sub cmdWrite_Click()
Dim lBytesWritten As Long
Dim BytesToWrite As Long, wData As Integer
If setFlg = False Then
MsgBox "Please click the Setup Button to do the setup First"
Exit Sub
End If
wData = txtWdata.Text
BytesToWrite = comDCB.ByteSize
openSuccess = WriteFile(hPort, wData, BytesToWrite, lBytesWritten, comOverlap)
End Sub
' Write data to serial port.
strData = JsonConverter.ConvertToJson(transaction, Whitespace:=3) & Chr$(13)
lngSize = Len(strData)
lngStatus = CommWrite(intPortID, strData)
If lngStatus <> lngSize Then
' Handle error.
End If
Private Sub cmdRead_Click()
Dim lBytesRead As Long
Dim BytesToRead As Long, rData As Integer
If setFlg = False Then
MsgBox "Please click the Setup Button to do the setup First"
Exit Sub
End If
BytesToRead = comDCB.ByteSize
openSuccess = ReadFile(hPort, rData, BytesToRead, lBytesRead, comOverlap)
txtRdata.Text = CStr(rData)
End Sub
Missing data in VBAlngStatus = CommRead(intPortID, strData, 14400)
Set rs = db.OpenRecordset("tblEfdReceipts")
If lngStatus > 0 Then
' Process data.
Set JSONS = JsonConverter.ParseJson(strData)
ElseIf lngStatus < 0 Then
Beep
MsgBox "There is no data to updated
' Handle error.
On Error Resume Next
End If
' Process data.
Z = 2
For Each item In JSONS
With rs
.AddNew
rs![TPIN] = item("TPIN")
rs![TaxpayerName] = item("TaxpayerName")
rs![Address] = item("Address")
rs![ESDTime] = item("ESDTime")
rs![TerminalID] = item("TerminalID")
rs![InvoiceCode] = item("InvoiceCode")
rs![InvoiceNumber] = item("InvoiceNumber")
rs![FiscalCode] = item("FiscalCode")
rs![TalkTime] = item("TalkTime")
rs![Operator] = item("Operator")
rs![Taxlabel] = item("TaxItems")("TaxLabel")
rs![CategoryName] = item("TaxItems")("CategoryName")
rs![Rate] = item("TaxItems")("Rate")
rs![TaxAmount] = item("TaxItems")("TaxAmount")
rs![VerificationUrl] = item("TaxItems")("VerificationUrl")
rs![INVID] = Me.InvoiceID
rs.Update
End With
Z = Z + 1
Next
rs.Close
Set rs = Nothing
Set db = Nothing
Set JSONS = Nothing
I don't see anything in the VB6 code that will stop you from copy-paste it to Access VBA...probably the "missing" parts are code parts that are located somewhere in the sample.
I'm not sure what you mean by your last comment. How is that relevant to your problem?
Have you seen this:
http://www.thescarms.com/vbasic/commio.aspx
This references how to work with serial ports in VBA, and might be a better (easier) fit than trying to convert VB6 code.