0
votes
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

  1. when i click Command1 i found an error Invalid Argument : 10014
    at >>Winsock1.SendData sendBuff << below Label3 my application cannot continues
  2. when i click Command2 2 times it can continues without application close
  3. 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)
    thanks

    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
    
2
Try showing us which lines the errors occur on.Deanna
"Winsock1.SendData sendBuff" in Command1_Click below the Label3TosZa BaaTeeSood
Can you try to explain more about what you are trying to do with the code you have provided?Shane Wealti
I'm supposed to have 4 PCs, 1st PC is running this program. 3 PCs running client program. and 1 of 3 PCs is offline when the 1st PC send message to the clients it has an error and application was closed. I want the program on 1st PC can continues without closing.TosZa BaaTeeSood

2 Answers

0
votes

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:

What's the difference between On Error Resume Next and On Error GoTo.

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.

0
votes

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