VB6 Winsock 错误无效参数 10014
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”不在线,我希望
- 当我单击 Command1 时我的应用程序可以继续,我发现错误无效参数:10014
at >>Winsock1.SendData sendBuff <<在 Label3 下面,我的应用程序无法继续 - 当我单击 Command2 2 次时,它可以在不关闭应用程序的情况下继续
当我单击 Command3 时,它可以在不关闭应用程序的情况下继续
我的问题是 1.) 和 2.) 有什么区别?和
对于我的问题,“On Error Resume Next”和“On Error GoTo”有什么区别?
(** 我对我的英语水平感到抱歉)
谢谢私有子Command6_Click() 将 i 调暗为整数 Command6.Enabled = False 出错时转到 BeginLoop Winsock1.RemoteHost =“Andon-eds-1” Winsock1.SendData“XXXXX” 开始循环: 继续下一步 对于 i = 0 到 2 Winsock1.RemoteHost =“Andon-eds-”&我 Winsock1.SendData“XXXXX” 调试.打印错误编号'0'0'0 下一个 出错时转到测试标签 我 = 100 / 0 Command6.Enabled = True 退出子程序 测试标签: 结束子
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
'the host name "andon-eds-1" is not online and i want my application can continues
- when i click Command1 i found an error Invalid Argument : 10014
at >>Winsock1.SendData sendBuff << below Label3 my application cannot continues - when i click Command2 2 times it can continues without application close
when i click Command3 it can continues without application close
my question are what's the difference between 1.) and 2.) ? and
what's difference between On Error Resume Next and On Error GoTo for my problem ?(** i'm sorry about my english skills)
thanksPrivate 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你想用代码做什么,所以我无法回答你的整个问题,但我可以回答你问题的这一部分:
如果发生错误,Resume next 将导致执行继续到下一行代码。对于 On Error GoTo,这会将您的代码转到 On Error GoTo 后面的代码部分中 GoTo 之后指定的标签。
I'm not sure what you are trying to do with the code so I can't answer your entire question but I can answer this part of your question:
Resume next will cause execution to go on to the next line of code if an error happens. For On Error GoTo, that will take your code to the label specified after the GoTo in the section of code that follows the On Error GoTo.
错误 10014 (WSAEFAULT) 很糟糕地址
系统在尝试使用调用的指针参数时检测到无效的指针地址。如果应用程序传递无效的指针值,或者缓冲区的长度太小,则会发生此错误。例如,如果作为 sockaddr 结构的参数的长度小于 sizeof(sockaddr)。
检查机器
“andon-eds-1”
是否可以正常ping通Error 10014 (WSAEFAULT) is Bad Address
The system detected an invalid pointer address in attempting to use a pointer argument of a call. This error occurs if an application passes an invalid pointer value, or if the length of the buffer is too small. For instance, if the length of an argument, which is a sockaddr structure, is smaller than the sizeof(sockaddr).
Check that the machine
"andon-eds-1"
can be pinged ok