首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

多谢,网络方面,多谢,小弟我爱你们

2012-01-07 
谢谢,网络方面,谢谢,我爱你们PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventA

谢谢,网络方面,谢谢,我爱你们
Private   Sub   Button1_Click(ByVal   sender   As   System.Object,   ByVal   e   As   System.EventArgs)   Handles   Button1.Click
                Dim   siteResponds   As   Boolean   =   False
                Dim   i   As   Short
                For   i   =   1   To   255
                        Label1.Text   =   i
                        siteResponds   =   My.Computer.Network.Ping( "192.168.1. "   &   i.ToString)
                        If   siteResponds   =   True   Then
                                MsgBox( "192.168.1. "   &   i.ToString   &   "连通 ")
                                'Else
                                '         MsgBox( "192.168.1. "   &   i.ToString   &   "连不通 ")
                        End   If
                Next   i
                MsgBox( "over ")

        End   Sub
我的路由器是1,我是2,为什么过了2后label1就没了变化,程序也(没有响应),还有,怎么得到自己的IP

[解决办法]
Imports System.Threading
Public Class Form1
Delegate Sub InvokeDelegate()
Dim i As Short
Dim hh As Thread
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
hh = New Thread(AddressOf ping)
hh.Start()

End Sub

Private Sub ping()
Dim siteResponds As Boolean = False
Try
For i = 1 To 255
Label1.BeginInvoke(New InvokeDelegate(AddressOf updateinfo))
siteResponds = My.Computer.Network.Ping( "192.168.1. " & i.ToString)
If siteResponds = True Then
MsgBox( "192.168.1. " & i.ToString & "连通 ")
'Else
' MsgBox( "192.168.1. " & i.ToString & "连不通 ")
End If
Next i

Catch ex As Exception

End Try
MsgBox( "over ")
End Sub

Private Sub updateinfo()
Label1.Text = i
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
hh.Abort()
End Sub
End Class


给分就行了,hoho

热点排行