ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

´ú¸ÕIP

´ú¸ÕIP

¤U¦Cµ{¦¡¬°´ú¸Õipªºµ{¦¡¡A¦bxp ¤ÎOFFICE 2003¤U¥i¥¿±`°õ¦æ¡A¦ý¦bWindows7¤Îoffice 2007«hµLªk°õ¦æ¡A½Ð°Ý¸Ó¦p¦ó­×§ï¡H·Ð½ÐÀ°¦£¸Ñµª¡A¤£³Ó·P¿E¡I

Public blnok As Boolean

Public Sub iptest()
Ping ("10.18.22.5")
Cells(1, 1) = blnok
End Sub

Function Ping(strAddr As String) As String
blnok = GetObject("winmgmts:").Get("NetDiagnostics=@").Ping(strAddr, Ping)
End Function
Às

¦^´_ 1# linderlong
¸Õ¸Õ¬Ý¥Î¤U¦C Function ¬Ý¬Ý¡G
  1. Public Sub iptest()
  2.     MsgBox Ping("10.18.22.5")
  3. End Sub
½Æ»s¥N½X
  1. Private Function Ping(strAddr As String) As String
  2.     Dim strTmpFile As String
  3.    
  4.     strTmpFile = Environ("TEMP") & "\PingResult.txt"   '  ·Ç³Æ«Ø¼È¦sÀɦb Windows Temp ¥Ø¿ý¤U
  5.     '  «Ø¥ß WScript ª«¥ó Shell Ãþ§O , ¨Ï¥Î Run ¤èªk , ©I¥s¥~³¡«ü¥O Ping ( ¨Ãµ¥«Ý¨ä°õ¦æµ²§ô )
  6.     CreateObject("WScript.Shell").Run Environ("COMSPEC") & " /c PING " & strAddr & " > " & strTmpFile, 0, True
  7.     '  PS : "Ping IP¦ì¸m > XXÀÉ®×" ³o¸Ì¬O¨Ï¥Î > ¨Ó±N Ping µ²ªG¼g¨ìÀɮ׸Ì
  8.     '  ( ·íµM¤]¥i Call API CreatePipe ¨ÓŪ¨ú©R¥Oµ²ªG )
  9.     '  Ping ¬O¤@ºØ¤½¥Îµ{¦¡¡A¥i¥HÅçÃÒ¤@©Î¦h­Ó»·ºÝ¥D¾÷³s½u¡C
  10.     '  Ping «ü¥O¥Î ICMP ¦^À³­n¨D©M¦^À³¦^ÂЮM¸Ë³nÅé¨Ó¨M©wºô¸ô¤Wªº¯S®í IP ¨t²Î¬O§_¥¿±`¹B§@¡C
  11.     '  Ping ¹ï¶EÂ_ IP ºô¸ô©Î¸ô¥Ñ¾¹¥¢±Ñ«D±`¦³¥Î¡C
  12.     '  Internet Control Message Protocol (ICMP)
  13.     '  TCP/IP ²Õ¥ó¤¤¥²­nªº¤@ºØºûÅ@³q°T¨ó©w¡A¥i³ø§i¿ù»~¨Ã¤¹³\²©ö³s½u¡C
  14.     '  Ping ¤u¨ã¥Î¨Ó°õ¦æ TCP/IP ºÃÃø±Æ¸Ñªº ICMP¡C
  15.     '  ¸Ô²Ó»¡©ú¤Î¥Îªk¥i°Ñ¦Ò:
  16.     '  ms-its:%WINDIR%\Help\ntcmds.chm::/ping.htm
  17.     '  ms-its:%WINDIR%\Help\ntcmds.chm::/ping.htm
  18.     '  ms-its:%WINDIR%\Help\tcpip.chm::/sag_TCPIP_pro_PingConnect.htm
  19.     '  ms-its:%WINDIR%\Help\tcpip.chm::/sag_TCPIP_pro_Ping.htm
  20.     '  «Ø¥ßÀɮרt²Îª«¥ó,¥Î¨Ó¶}±Ò¼È¦s¤å¦rÀÉ,¨ÃŪ¨ú¤º®e ( ¨ú¦^ Pingªºµ²ªG )
  21.     Ping = CreateObject("Scripting.FileSystemObject").OpenTextFile(strTmpFile).ReadAll
  22.     Ping = Replace(Ping, vbCrLf, "", 1)
  23.    
  24.     On Error Resume Next
  25.     Kill strTmpFile         '  §R°£¼È¦sÀÉ
  26. End Function
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ linderlong ©ó 2013-8-28 08:59 ½s¿è

¦^´_ 2# c_c_lai

·PÁ¤j¤jªº«ü¾É¡I¤w¥i¥H¨Ï¥Î¡A¦ý³t«×¤W²¤¬°½wºC¡A¤£ª¾¦³µL¤èªk´£¤É´ú¸Õªº³t«×¡Aµ{¦¡¦p¤U¡G
°²³]a1¦Üa10Àx¦s®æ¤º®e¦U¬°100.18.22.1¦Ü100.18.22.10¡A¦b§Úªº¹q¸£¤W°õ¦æ§¹¤@¦¸¡A­n¶O®É45¬í¡A®É¶¡¤W¤Ó¤[¤F¡A¤£ª¾¦p¦óÁYµu®Éµ{¡HÁÂÁ¡I

Public Sub iptest()
  Columns("B:B").Select
  Selection.ClearContents
  Range("A1").Select
  ¶O®É = Timer
  i = 1
  Do While Cells(i, 1) <> ""
    Cells(i, 2) = Ping(Cells(i, 1))
    i = i + 1
  Loop
  Cells(1, 3) = Timer - ¶O®É
End Sub

Private Function Ping(strAddr As String) As String
    Dim strTmpFile As String
    strTmpFile = Environ("TEMP") & "\PingResult.txt"   '  ·Ç³Æ«Ø¼È¦sÀɦb Windows Temp ¥Ø¿ý¤U
    CreateObject("WScript.Shell").Run Environ("COMSPEC") & " /c PING -n 1 " & strAddr & " > " & strTmpFile, 0, True
    Ping = CreateObject("Scripting.FileSystemObject").OpenTextFile(strTmpFile).ReadAll
    Ping = Replace(Ping, vbCrLf, "", 1)
    On Error Resume Next
    Kill strTm
End Function
Às

TOP

¦^´_ 3# linderlong
§Ú³s¤W Google ¬ù»Ý¤­¬í¡A¦p¤U¹Ï©Ò¥Ü¡G

¦p¥H .1 ¨ì .10 ­n 45 ¬í (°»´ú¥~³¡ IP)¡A
À³¬O¦X²z½d³ò¡C

TOP

¥Ñ©ó­n´ú¸Õªºip¦³ªñ¦Ê­Ó¡A¦p¦¹¤@¨Ó«h¶·­n¦nªøªº®É¶¡¡C
°²­Y¨Æ¥ý¦bd:\iptest\ªº¥Ø¿ý¤U¥ý«Ø¦n­n´ú¸Õipªº10­Ó§å¦¸ÀÉ¡]¤º®e¬°Ping -n 1 100.18.22.1 > D:\iptest\1.txt¡^¡A¦A¥H¤U¦Cµ{¦¡°õ¦æ´ú¸Õ«h¶È¶·¤£¨ì2¬íªº®É¶¡¡A¦ý¥Ñµ{¦¡¹L©ó¤¾ªø¡A¤~·Q½Ð±Ð¬Ý¬Ý¬O§_¦³µ{¦¡Â²¼ä¥B¶O®Éµuªº¤èªk¡AÁÂÁ¡I

Public Sub ¤u§@()
  '´ú¸Õip
  ¶O®É = Timer
  ¦C = 1
  For i = 1 To 10
    §å¦¸ÀÉ = "d:\iptest\" & i & ".BAT"
    a = Shell(§å¦¸ÀÉ, 0)
  Next i
  
  ¥ð®§ = Timer
  Do While Timer - ¥ð®§ < 1
    DoEvents
  Loop
   
  'Ū¨úµ²ªG
  For i = 1 To 10
    ¤å¦rÀÉ = "d:\iptest\" & i & ".TXT"
    ¥N½X = FreeFile    ' ¨ú±o¥¼¨Ï¥ÎªºÀÉ®×¥N½X¡C
    Open ¤å¦rÀÉ For Input As #¥N½X
    cells(i, 2) = Input(120, #¥N½X)
    Close #¥N½X    ' Ãö³¬ÀɮסC
  Next i
  cells(1, 3) = Timer - ¶O®É
End Sub
Às

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-8-28 14:33 ½s¿è

¦^´_ 5# linderlong
§A¸ÕµÛ¥Î Shell command ªº¤è¦¡°õ¦æ¬Ý¬Ý¡G
  1. Sub Test()
  2.     Dim strIP As String, sp As Variant, RetVal
  3.     Dim cts As Integer, xi As Integer
  4.    
  5.     strIP = "100.18.22.1,100.18.22.2,100.18.22.3,100.18.22.4,100.18.22.5,100.18.22.6,100.18.22.7,100.18.22.8,100.18.22.9,100.18.22.10"
  6.    
  7.     sp = Split(strIP, ",")
  8.     cts = 0
  9.     For xi = 0 To UBound(sp)
  10.         cts = cts + 1
  11.         '  RetVal = Shell("command.com /c Ping -n 1 100.18.22.1 > D:\iptest\1.txt")
  12.         RetVal = Shell("command.com /c Ping -n 1 " & sp(xi) & " > " & ThisWorkbook.Path & "\iptest" & cts & ".txt")
  13.         ¤u§@ªí1.Cells(cts, 1) = sp(xi)
  14.     Next xi
  15. End Sub
½Æ»s¥N½X

TOP

¥¿¬ã¨s¤¤¡A¤Q¤À·P¿E¡IÁÂÁ¡I
Às

TOP

¦^´_ 6# c_c_lai
°²³]a1¦Üa10Àx¦s®æ¤º®e¦U¬°100.18.22.1¦Ü100.18.22.10¡A¦Ó±Npingªºµ²ªG¨Ì§Ç©ñ¦bB1¦ÜB10ªºÀx¦s®æ¤W¡Aµ{¦¡¦p¤U¡A¤w¸g´ú¸Õ¦bxp¤ÎW7¡A32¦ì¤¸¥i¥H°õ¦æ¡A¦ý¦bW7¡A64¦ì¤¸¨t²Î«h¦b    RetVal = Shell("command.com /c Ping -n 1 " & Cells(i, 1) & " > " & ThisWorkbook.Path & "\" & i & ".txt") ³o¦æ«ü¥Oµo¥Í¿ù»~¡A½Ð°Ý¦p¦ó­×¥¿¡HÁÂÁ¡I

¥t¥~¤£ª¾¦³µL¤èªkª½±µ±N ping ªºµ²ªGª½±µ¼g¤JB1¦ÜB10ªºÀx¦s®æ¡A¦Ó¤£¥²¸g¥Ñ¼g¤JtxtÀÉ«á¡A¦A¶}±ÒtxtÀɱN¨ä¼g¤JB1¦ÜB10Àx¦s®æ¤º¡C¤Q¤À·P¿E¡I

Sub Test()
  Columns("B:C").Select
  Selection.ClearContents
  ¶O®É = Timer
  For i = 1 To 10
    RetVal = Shell("command.com /c Ping -n 1 " & Cells(i, 1) & " > " & ThisWorkbook.Path & "\" & i & ".txt")
  Next i
  
  ¥ð®§ = Timer
  Do While Timer - ¥ð®§ < 2
    DoEvents
  Loop
   
  For i = 1 To 10
    ¤å¦rÀÉ = ThisWorkbook.Path & "\" & i & ".TXT"
    ¥N½X = FreeFile    ' ¨ú±o¥¼¨Ï¥ÎªºÀÉ®×¥N½X¡C
    Open ¤å¦rÀÉ For Input As #¥N½X
    ¦rªø = LOF(¥N½X)
    Cells(i, 2) = Input(¦rªø, #¥N½X)
    Close #¥N½X    ' Ãö³¬ÀɮסC
  Next i
  Cells(1, 3) = Timer - ¶O®É
End Sub
Às

TOP

¦^´_ 8# linderlong
½Ð±N Cells(i, 1) ©ú½T«ü©w ¤u§@ªí³æ¤§ÂkÄÝ¡C
Ä´¦p¡G Sheet1.Cells(i, 1) µ¥¡C

TOP

¦^´_ 9# c_c_lai
¤w§ï¬°sheet1.cells(i,1)¦bw7,64¦ì¤¸,office2007¤U¡A¤´ÂµLªk°õ¦æ¡A¤£ª¾¬°¦ó­ì¦]¡HÁÂÁ¡I
Às

TOP

        ÀR«ä¦Û¦b : §Ú­Ì­n°µ¦nªÀ·|ªºÀô«O¡A¤]­n°µ¦n¤º¤ßªºÀô«O¡C
ªð¦^¦Cªí ¤W¤@¥DÃD