Private Sub Form_Load()
Winsock1.RemotePort = 22222
Winsock1.Protocol = sckUDPProtocol
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
Dim sendBuff As String
sendBuff = "XXXXX"
Label1:
On Error GoTo Label2
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
Label2:
Winsock1.Close
Winsock1.Protocol = sckUDPProtocol
Winsock1.RemotePort = 22222
Winsock1.LocalPort = 0
Label3:
On Error GoTo EndOfSub
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
EndOfSub:
Command1.Enabled = True
End Sub
Private Sub Command2_Click()
Command2.Enabled = False
On Error GoTo EndOfSub
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData "XXXXX"
EndOfSub:
Command2.Enabled = True
End Sub
Private Sub Command3_Click()
On Error Resume Next
Command3.Enabled = False
Dim sendBuff As String
sendBuff = "XXXXX"
PrintWinsockProperty
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
PrintWinsockProperty
Winsock1.Close
Winsock1.Protocol = sckUDPProtocol
Winsock1.RemotePort = 22222
Winsock1.LocalPort = 0
PrintWinsockProperty
Winsock1.RemoteHost = "andon-eds-1"
Winsock1.SendData sendBuff
PrintWinsockProperty
Command3.Enabled = True
End Sub
'主机名“andon-eds-1”不在线,我希望我的申请可以继续
当我点击Command3时,它可以继续而无需申请关闭
我的问题是1.)和2.)之间的区别是什么?和
对于我的问题,On Error Resume Next和On Error GoTo之间的区别是什么?
(**我对我的英语技能感到抱歉)
感谢
Private Sub Command6_Click()
Dim i As Integer
Command6.Enabled = False
On Error GoTo BeginLoop
Winsock1.RemoteHost = "Andon-eds-1"
Winsock1.SendData "XXXXX"
BeginLoop:
Resume Next
For i = 0 To 2
Winsock1.RemoteHost = "Andon-eds-" & i
Winsock1.SendData "XXXXX"
Debug.Print Err.Number '0 '0 '0
Next
On Error GoTo TestLabel
i = 100 / 0
Command6.Enabled = True
Exit Sub
TestLabel:
End Sub
答案 0 :(得分:0)
我不确定您要对代码做什么,所以我无法回答您的整个问题,但我可以回答您问题的这一部分:
On Error Resume Next和On Error GoTo之间有什么区别。
如果发生错误,继续下一步将导致执行继续执行下一行代码。对于On Error GoTo,这会将您的代码带到On Error GoTo之后的代码部分中的GoTo之后指定的标签。
答案 1 :(得分:0)
Error 10014 (WSAEFAULT) is Bad Address
系统在尝试使用调用的指针参数时检测到无效指针地址。如果应用程序传递无效指针值,或者缓冲区的长度太小,则会发生此错误。例如,如果参数的长度(sockaddr结构)小于sizeof(sockaddr)。
检查机器"andon-eds-1"
是否可以正确