Using MSCOMM to read a scale on com one, her eis the code:
Private Sub Command1_Click()
Dim value As String
Dim counter As Integer
counter = 0
frmMain.MSComm1.CommPort = 1
frmMain.MSComm1.Settings = "9600,E,7,1"
frmMain.MSComm1.InputLen = 7
frmMain.MSComm1.PortOpen = True
frmMain.MSComm1.Output = "W" & Chr$(13)
MsgBox value, vbCritical ***************
buffer$ = buffer$ & frmMain.MSComm1.Input
counter = counter + 1
txtIWeight.Text = Mid(buffer$, 2, 6)
txtIWeight.Text = Val(txtIWeight.Text)
frmMain.MSComm1.PortOpen = False
End Sub
The app reads the scale just fine and places the value in the textbox, however it will only work with the line marked with asterisks above. If I take out the msgbox line , I get a null or zero value return from the scale? Any Ideas? How is a MSGBOX and a MSCOMM input connected in this way?
Private Sub Command1_Click()
Dim value As String
Dim counter As Integer
counter = 0
frmMain.MSComm1.CommPort = 1
frmMain.MSComm1.Settings = "9600,E,7,1"
frmMain.MSComm1.InputLen = 7
frmMain.MSComm1.PortOpen = True
frmMain.MSComm1.Output = "W" & Chr$(13)
MsgBox value, vbCritical ***************
buffer$ = buffer$ & frmMain.MSComm1.Input
counter = counter + 1
txtIWeight.Text = Mid(buffer$, 2, 6)
txtIWeight.Text = Val(txtIWeight.Text)
frmMain.MSComm1.PortOpen = False
End Sub
The app reads the scale just fine and places the value in the textbox, however it will only work with the line marked with asterisks above. If I take out the msgbox line , I get a null or zero value return from the scale? Any Ideas? How is a MSGBOX and a MSCOMM input connected in this way?