10电气《计算机网络》课程论坛

Would you like to react to this message? Create an account in a few clicks or log in to continue.
10电气《计算机网络》课程论坛

10电气《计算机网络》课程论坛


3 posters

    第二问如何测试本机是否连网?答案征集9.10

    靖炜
    靖炜


    帖子数 : 58
    注册日期 : 12-09-05

    第二问如何测试本机是否连网?答案征集9.10 Empty 第二问如何测试本机是否连网?答案征集9.10

    帖子  靖炜 周一 九月 10, 2012 4:02 am

    如何测试本机是否连网?
    彭威
    彭威


    帖子数 : 48
    注册日期 : 12-09-06

    第二问如何测试本机是否连网?答案征集9.10 Empty 回复: 第二问如何测试本机是否连网?答案征集9.10

    帖子  彭威 周一 九月 10, 2012 4:12 am

    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Form_Load()
    Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
    Command1.Move (Me.Width - Command1.Width) \ 2, (Me.Height - Command1.Height) \ 2
    End Sub

    Private Sub Command1_Click()
    Dim linkyn As Boolean
    fname = App.Path & "\test.bat"
    Open fname For Output As #1
    Print #1, "ping 192.168.1.1 -n 1 > c:\pingtest.txt"
    Close #1

    DoEvents
    Shell fname, vbHide
    Sleep 2000 '延长时间2秒,等待test.bat的结果

    linkyn = False
    Open "c:\pingtest.txt" For Input As #1
    Do While Not EOF(1)
    Line Input #1, x
    If InStr(x, "Reply from") > 0 Then
    n = InStr(x, ": ")
    Gateway = Mid(x, n + 1)
    MsgBox "连接网络成功" & Chr(13) & "以下是ping的资料" & Chr(13) & Gateway
    linkyn = True
    Exit Do
    End If
    Loop
    Close #1
    If linkyn = False Then
    MsgBox "无法联线成功"
    End If
    Kill fname
    Kill "c:\pingtest.txt"
    End Sub


    雷兵兵
    雷兵兵


    帖子数 : 50
    注册日期 : 12-09-05
    年龄 : 32
    地点 : 黄石职业技术学院

    第二问如何测试本机是否连网?答案征集9.10 Empty 回复: 第二问如何测试本机是否连网?答案征集9.10

    帖子  雷兵兵 周一 九月 10, 2012 4:14 am

    彭威 写道:Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Form_Load()
    Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
    Command1.Move (Me.Width - Command1.Width) \ 2, (Me.Height - Command1.Height) \ 2
    End Sub

    Private Sub Command1_Click()
    Dim linkyn As Boolean
    fname = App.Path & "\test.bat"
    Open fname For Output As #1
    Print #1, "ping 192.168.1.1 -n 1 > c:\pingtest.txt"
    Close #1

    DoEvents
    Shell fname, vbHide
    Sleep 2000 '延长时间2秒,等待test.bat的结果
    这是什么东西?? 豆豆哥能解释下么?

    linkyn = False
    Open "c:\pingtest.txt" For Input As #1
    Do While Not EOF(1)
    Line Input #1, x
    If InStr(x, "Reply from") > 0 Then
    n = InStr(x, ": ")
    Gateway = Mid(x, n + 1)
    MsgBox "连接网络成功" & Chr(13) & "以下是ping的资料" & Chr(13) & Gateway
    linkyn = True
    Exit Do
    End If
    Loop
    Close #1
    If linkyn = False Then
    MsgBox "无法联线成功"
    End If
    Kill fname
    Kill "c:\pingtest.txt"
    End Sub



      目前的日期/时间是周日 十一月 24, 2024 11:48 pm