Private Const IP_Addr = "192.168.0." Private Const Interval = 0.3 Private Sub StopTime(st As Single) 'タイマー関数を使って Sleep 関数と同様の関数を作成 Dim sngSt As Single sngSt = Timer Do While Timer - sngSt < st DoEvents Loop End Sub Private Sub Command1_Click() Dim ip As Integer Text1.Text = "" For i = 1 To 254 Winsock1.RemoteHost = IP_Addr & CStr(i) Winsock1.RemotePort = 139 'NET BIOSポート Winsock1.Connect StopTime Interval If Winsock1.State = 7 Then '接続完了 Text1.Text = Text1.Text & Winsock1.RemoteHost & _ "::Active!(" & Winsock1.State & ")" & vbCrLf Else '接続失敗 Text1.Text = Text1.Text & Winsock1.RemoteHost & _ "::Closed!(" & Winsock1.State & ")" & vbCrLf End If Text1.SelStart = Len(Text1.Text) Winsock1.Close Next MsgBox "検索終了" End Sub