Imports System.IO
Imports System.Threading
Imports System.Diagnostics
Public Class Form1
Dim A(254) As String
Function ping(ByVal IP As Integer) As String
Dim IPAddress As String
IPAddress = "10.0.2." & IP
If My.Computer.Network.Ping(IPAddress) Then
A(IP) = "OK"
Else
A(IP) = "NG"
End If
End Function
Private Sub Button1_Click_1(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Dim mythread(254) As Thread
Dim i As Integer
‘创建线程对象
For i = 1 To 254
mythread(i) = New Thread(AddressOf ping)
Next
‘执行线程
For i = 1 To 254
mythread(i).Start(i)
Next
‘等待线程完成
For i = 1 To 254
mythread(i).Join()
TextBox1.Text = A(i)
Next
End Sub
End Class