請教各位關于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重新編輯 ]