Dear All;
I need help here to fix the the VBA Code below, what I'm trying to do is to have the pre converted Json string data and then send it to the rs 232 and receive the response at the the same time. The opening part of the machine is fine but the writing part show that there is no data supplied into the port, that is where my problem is.
' Write data to serial port.
strData = JsonConverter.ConvertToJson(transaction, Whitespace:=3) & Chr$(13)
lngStatus = CommWrite(intPortID, strData)
lngSize = Len(strData)
If lngStatus <> lngSize Then
Beep
MsgBox "No data found"
' Handle error.
End If
Suprisingly if I send the data directly to the text file using the VBA code below I will be able to get the data if I open that text file as per link below:
Dim json As String
Dim theFileName As Variant
json = JsonConverter.ConvertToJson(transaction, Whitespace:=3) & Chr$(13)
theFileName = "C:\Users\admini\Desktop\Leaders\VBA Json.txt"
Dim handle As Integer
handle = FreeFile
Open theFileName For Output As #handle
Print #handle, json 'jsonSerialization
Close #handle