请教各位关于VB6.0与S7-200以太网通讯(Winsock),本人刚接触VB6.0。
要求:对Q0.3置1
VB6.0程序如下
Private Sub Command1_Click()
Dim sendstr(7) As Byte
sendstr(0) = &H1 '站地址
sendstr(1) = &H5 '功能码
sendstr(2) = &H0
sendstr(3) = &H3 '目标地址
sendstr(4) = &HFF
sendstr(5) = &H0 '线圈置1
sendstr(6) = &H0 '校验码
sendstr(7) = &H0 '校验码
Dim astr As String
Dim i As Integer
For i = 0 To 7
astr = astr & Chr(sendstr(i))
Next
SockServer.SendData astr
End Sub
Private Sub Form_Load()
SockServer.LocalPort = 2000
SockServer.RemoteHost = "192.168.1.60" ‘PLC地址
SockServer.RemotePort = 1 ’PLC站地址
End Sub
用以太网链接测试,没效果。
这个程序那个地方有问题?应该怎么改。
[ 此帖被beiye1234在2011-04-16 11:21重新编辑 ]