Hi Everyone i am trying to write a software that aquires the measurements taken by a scale at a weighbridge. I have written the below code, however, i am not getting any Mscomm1.input information. What am i not doing right?
Please find the code below:
Thank you for your help!
Please find the code below:
Code:
Private Sub UserForm_Initialize()
Call Ports.GetPorts
End Sub
Public Sub GetPorts()
With MComm
On Error GoTo PortTest:
Dim i As Long
Dim ComPortAvailable As Boolean
For i = 1 To 400
.MSComm1.CommPort = i
.MSComm1.PortOpen = True
If .MSComm1.PortOpen Then
.cmb.AddItem VBA.str$(i)
.MSComm1.PortOpen = False
ComPortAvailable = True
End If
Next
End With
PortTest:
Resume Next
End Sub
Private Sub cmdConnect_Click()
With MSComm1
.CommPort = cmb.value
.Settings = "9600,n,8,1"
.RThreshold = 1
.InBufferSize = 4096
.PortOpen = True
.SThreshold = 1
.Handshaking = 2 - comRTS
.Output = "AT"
Call GetData
End With
Private Sub GetData()
Dim MyData As String
'MSComm1.InputLen = 0
MSComm1.Output = "AT"
MyData = MSComm1.Input
TXT1.Text = MyData
MSComm1.PortOpen = False
End Sub
End Sub
Thank you for your help!