Hello,

I'm trying to send/retrieve ASCII data to my COM1. The codes are below. When sending "SP38=100", sometimes it sends it, but other time It would not. It sends "S3=00" rather than "SP38=100".

What's going on? Am I doing something wrong?

Using VB6.0

Thanks,
Tin

// assume port is already openned
Private Sub cmdSetValue_Click()

Dim strCommand As Variant

strCommand = "SP38=100"
sendCommand (strCommand)
End Sub

Function sendCommand(sCommand As Variant)

Dim ret As Integer

MSComm1.Output = sCommand

Do
ret = DoEvents()
Loop Until MSComm1.OutBufferCount = 0

' MsgBox Val(MSComm1.Input)

If Err Then
MsgBox Error$, 48
Exit Function
End If

End Function