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