Help us understand the problem. What is going on with this article?

Excel VBAでnslookup

More than 5 years have passed since last update.

使い慣れないので記録を取っておく意味でエントリーしておく.
自前の関数は「標準モジュール」に配置する... と.

 nslookup.bas
Option Explicit

Function nslookup(ip As String) As String

  Dim wsh, exec, cmd, res As String, i As Integer
  Dim buf() As String

  Set wsh = CreateObject("WScript.Shell")
  cmd = "nslookup " & ip

  Set exec = wsh.exec("%ComSpec% /c " & cmd)

  Do While exec.Status = 0
    DoEvents
  Loop

  res = exec.StdOut.ReadAll

  buf = Split(res, vbCrLf)

  For i = 0 To UBound(buf)
    If Left(buf(i), 5) = "Name:" Or Left(buf(i), 3) = "名前:" Then
      host_name = Mid(buf(i), 10)
    End If
  Next i

End Function
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away