Currently, I have connected two computers via serial cables and a null modemn adaptor. I have set the two computers up to simulate a VB application that will need to communicate with a plc computer that will reply with a hex string, upon receiving an ASCII "S".
Private Sub scTimer_Timer()
On Error GoTo ERRH
If msComm.PortOpen Then
msComm.Output = "S"
msComm.PortOpen = True
MsgBox "ERROR ... TIMER WILL BE DISABLED." & Chr(13) & Err.Number & Chr(13) & Err.Description
scTimer.Enabled = False
Private Sub msComm_OnComm()
If msComm.CommEvent = comEvReceive Then
Text1.Text = Text1.Text + StrConv(msComm.Input, vbUnicode)
Text2.Text = ""
For y = 1 To Len(Text1.Text)
Text2.Text = Text2.Text & Chr(Val("&h" & (Mid(Text1.Text, y + 1, 2))))
y = y + 2
Basically, what happens is the hexadecimal string is received into text1.text and is converted into ASCII in Text2. The event is updated every three seconds, so the timer is set to resend the "S" every 3 seconds. The first time, everything works exactly as it should, however when it fires the second "S", the new data is just appended on to the previously received data in Text1. Everythin I try messes up the data I receive in Text1. Please let me know your suggestions!