Hi, I need help with visual basic 6 program or hardware of plc. I am trying to get vb6 program to read serial port that my plc s7-200 CPU 222 is conected to. I can not get the program to read anything at all. My code is (in vb6):
Private Sub cmdOpen_Click()
'opening the serial port
If MSComm1.PortOpen = False Then
MSComm1.CommPort = 1
MSComm1.Settings = "9600, N, 8, 1"
MSComm1.InputLen = 0 'to read the whole input buffer
MSComm1.PortOpen = True
MSComm1.Handshaking = comXOnXoff
Else
MsgBox "Connection has already been established", vbInformation, "Port opened"
End If
End Sub
Private Sub cmdDisplay_Click()
'to display the data from the receive buffer
MSComm1.InputMode = comInputModeBinary
txtDisplay.Text = MSComm1.Input
txtCharacters.Text = MSComm1.InBufferCount
End Sub
Please if anybody can tell me what is wrong with my code or give me a code that works, if posible a basic code (begginer) I would be very, very gratfull. If the code is ok, is there a problem with my connection with the plc, but I can download a code to a plc fine with the step7 template and also monitor the program how it works with the step7 program, so I do not think it is a hrdware/connection problem.
Do I have to tell or use some kind of comand (code) to make the plc to send me the information through the serial port.
Thank you.
Private Sub cmdOpen_Click()
'opening the serial port
If MSComm1.PortOpen = False Then
MSComm1.CommPort = 1
MSComm1.Settings = "9600, N, 8, 1"
MSComm1.InputLen = 0 'to read the whole input buffer
MSComm1.PortOpen = True
MSComm1.Handshaking = comXOnXoff
Else
MsgBox "Connection has already been established", vbInformation, "Port opened"
End If
End Sub
Private Sub cmdDisplay_Click()
'to display the data from the receive buffer
MSComm1.InputMode = comInputModeBinary
txtDisplay.Text = MSComm1.Input
txtCharacters.Text = MSComm1.InBufferCount
End Sub
Please if anybody can tell me what is wrong with my code or give me a code that works, if posible a basic code (begginer) I would be very, very gratfull. If the code is ok, is there a problem with my connection with the plc, but I can download a code to a plc fine with the step7 template and also monitor the program how it works with the step7 program, so I do not think it is a hrdware/connection problem.
Do I have to tell or use some kind of comand (code) to make the plc to send me the information through the serial port.
Thank you.