专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VB Dotnet

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

发布时间:2011-06-23 15:58:33 文章来源:www.iduyao.cn 采编人员:星星草
谢谢,网络方面,谢谢,我爱你们
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
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: