חלקם יעילים , חלקם פחות חלקם טובים חלקם לא. הנה פתרון נחמד , עקוב אחרי הקוד והוסף את האובייקטים המתאימים לפרוייקט ששלך:
Private Sub Check1_Click() If Check1 = 1 Then Timer1.Enabled = True Else Timer1.Enabled = False End Sub
Private Sub Command1_Click() Command1.Enabled = False On Error Resume Next With Winsock1 .Close .RemoteHost = Text1.Text .RemotePort = Val(Text2.Text) .Connect While .State = 6 DoEvents Wend 'MsgBox .State If .State = 0 Then Label1.Caption = "Default. Closed" If .State = 1 Then Label1.Caption = "Open" If .State = 2 Then Label1.Caption = "Listening" If .State = 3 Then Label1.Caption = "Connection pending " If .State = 4 Then Label1.Caption = "Resolving host" If .State = 5 Then Label1.Caption = "Host resolved" If .State = 6 Then Label1.Caption = "Connecting" If .State = 7 Then Label1.Caption = "Connected" If .State = 8 Then Label1.Caption = "Peer is closing the connection" If .State = 9 Then Label1.Caption = "Error" If .State = 7 Then Label2.Caption = "Client is up" Else Label2.Caption = "Client is down" End If .Close End With Command1.Enabled = True End Sub
Private Sub Text3_Change() Timer1.Interval = Val(Text3.Text) End Sub