Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How Can You Resolve A Hostname To An Ip?

anyone know? (in vb)

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
[HELP] How To Resolve Hostname In VB6?
May I know how to resolve hostname in VB6? Is it possible to?
I tried using nslookup and output it to a file, then i extract the IP from there. Is there any faster way??

Not Possible: How To Resolve A Hostname Into An IP Address!
I have a the simple application "How to Resolve a Hostname Into an IP Address" from vbnet run under VB 5.
It works fine on every PC with direct Internet connection, but not on our network with a TC IP Server and fixed IP-adresses
The problem is on our Win 2000 maschines as well on the Win 98 and Win NT maschines. So what can I do?
Any idea?

how can i get peoples hostname by using almost like a tracert??

Can anyone tell me how to change the DNS host name with VB, I know you can get the hostname with winsock but how do you change the hostname?

Hostname && IP From MAC
Is there a way to programmatically retrieve a hostname and IP address from a MAC address. I would like to keep a log of all IP address conflicts by typing in the MAC address that is returned with the error message and have it store "friendly" information like the hostname.


Get Hostname
Who would like to tell me how to get the hostname by host IP address?thanks.

Ping Hostname
i just need some sample code that is a module i call to which will ping a hostname on the network and return yes or no if they excist. preferbly with a changeable timeout of 300ms

bonus would be to scan a listbox of hostnames and remove those that dont excist

Getting The Hostname AND Computer Name From An IP????
Im after some code that will scan either the network OR range of IPs for a certain computername or user name..

Imagine a user called JohnnyBravo was logged on but i only knew his computer name. I need a way of turning the computername into the username, and vice versa. Any ideas?

Cheers guys!

Accquiring The Hostname
Does anymore have some VB code which will enable me to grab the Hostname of a remote machine given the IP Address?

I have written a program which will ping Server's & Routers and reports if the ping is successful or not. What I would like to do now is if the ping is not successful it will grab the hostname of the server and report which machine is not available instead of which IP address.

The command that I am using is IcmpSendEcho for the ping. Can this command grab the hostname or will I have to use something else?



Getting The HostName/IP From A Files URL?

I'm creating a Download Manager and I've come across a problem when trying to connect to the host.

Lets say we have the following URL to the File 'Blah.exe';


But to connect to the server and send the request for that file I need to know the Hosts name or IP so I can use,

Winsock.Connect Host, Port
There was a small part of my brain hoping that I could just use the Full URL as the host and VB/Winsock/The_VB_Goblin would automatically work out the Host and connect.

Well that didn't work of course, so then I figure (with the above example) well,


would be the host! So I wrote some code to get just that part of the URL.
Now for some servers this does work! YAY! But not for all servers, most of which won't even connect, which means of course that the bit between 'http://' and the first '/' isn't always the host.

I've tried searching the web and forums and the only code I can find will either give you the IP if you know the HostName or visaversa.

So my question is how do I get the HostName or IP from the big long files URL?


Ping Using Hostname Or IP
I am using the code that Hack provided in this thread for pinging.

This code works great for IP addresses. However this code does not support hostnames.

Does anyone know how to modify this code to include Hostnames?

I am looking for a function that can handle both hostnames and IP addresses. The output will be going to a list box (not a file).

Thanks for everyone's time and consideration.

Winsock Get Hostname
How can I get somebody's hostname (I have the IP) using the winsock dll (NOT OCX).

Find Out If Its IP Or Hostname?
what would the code for that be? because if its an IP i wanna do one thing, if its not, do something else



How To Convert Between IP And Hostname On A LAN
How would i go about this? I have the user enter either the IP of a machine or the hostname and I want to be able to detect the other. Tried the winsock control, anything else I can do?

Hostname Retrieval
so i just finished writing a program to retrieve a machine's network info and write it to a log, but then it hit's going to take alot of time to walk around to 2,000+ machines and run the program.

just out of curiosity, is there a way to retrieve all ip addresses and hostnames that are currently logged into a network from a single machine?

this would save alot of time as i wouldn't have to go around to 2,000+ machines and pull their info, and we all know smart laziness is the best form of laziness.

any help would be much appreciated..thanks in advance!

- brett

How Do I Get The Hostname Of My Machine :( ?
Hi Guys

How do I extract the hostname of my machine through Visual Basic. Please reply soon.



Resolving Hostname To Computer Name?
Hi there, in VB, how would I go about getting the computer name from the hostname its logged onto the local network with? Thanks.

Gathering Hostname And IP Information
This is what I want to do.. I want to be able to pull the users IP and hostname off of their computer when they run my ip so I can make a ip address database. I understand all sql and talking to the database. My question is pulling the hostname and ip of the computer. I will be running this on 98,2000,XP systems. Thanks for the help

Obtaining Hostname From IP Address
May i just check if there's anyway to obtain the hostname of a terminal from it's IP address???

tks in advance

How Can You Split A URL Into Hostname And File?

how can you transform these 3 into hostame and file? so, the above 3 would look like

Site File
1) /folder/folder/file.gif
2) /site/somefile.jpg
3) /file.exe

anyone know?

Hostname Setting Under Windows9X/2k
How do i set HostName environment variable in registry under windows 9x or 2000? Can somebody plaese help?

Finding Hostname Through VBScript

I think this is a simple one.

I'm using a WSHShell and I would like to know what command I can put into my .vbs file to find the hostname of the computer I am working on.

Please can anyone help?

Thank you.


Discoverying Computer Hostname In VB6
Is there a way I can access the host computers name using VB6?

Capturing Hostname Of The Users
In a multi-user environment if I want capture the names or ipaddress of the user who are currently logged on to the session

When I say sp_who from sybase database the names of the users shd be displayed

Can we capture this information using ado


HostName And Domain Using Winsock Or Inet
Is it possible get a host name from one remote ip and it's domain using winsock controls or/and inet controls?

I never tryed to do that, i need some explanations and maybe one or two exemples.

Edit: Donne

Winsock/returning Remote Hostname?
Ok, here's the deal. I'm writting a simple/to semi complicated telnet server and it's coming along nicely. But...

I don't have a clue how to get the hostname/ip of the client trying to connect.

Is there ANY documentation or examples anyone can point me in the direction of? Or can anyone explain the process I need to use to return this information?

Thanks. =).

Obtaining Hostname Of Local Machine
How can I obtain the hostname of my nt4 machine through VB?

hai friends,

           i have a doubt . HOw to find out the server host name and ip address in a lan. Can any one help. If possible send me a project . this forum is helping me a lot.

           Thanks a lot to all of u.have a nice day.




Problem In Resolving Ip Address From Hostname
I need to resolve the ip address from the hostname. i am doing the same in the following way.
this works properly in english version of windows. but i test in korean version of windows, it is now working.
it seems api functions are not doing correctly. am i doing something wrong? please clarify me. if any one knows the way to solve this problem please reply me immediately.

Option Explicit
Public Const IP_SUCCESS As Long = 0
Public Const MAX_WSADescription As Long = 256
Public Const MAX_WSASYSStatus As Long = 128
Public Const WS_VERSION_REQD As Long = &H101
Public Const MIN_SOCKETS_REQD As Long = 1
Public Const SOCKET_ERROR As Long = -1

Public Type WSADATA
wVersion As Integer
wHighVersion As Integer
szDescription(0 To MAX_WSADescription) As Byte
szSystemStatus(0 To MAX_WSASYSStatus) As Byte
wMaxSockets As Long
wMaxUDPDG As Long
dwVendorInfo As Long
End Type

Private Declare Function gethostbyname Lib "wsock32" _
(ByVal hostname As String) As Long

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(xDest As Any, _
xSource As Any, _
ByVal nbytes As Long)

Private Declare Function lstrlenA Lib "kernel32" _
(lpString As Any) As Long

Public Declare Function WSAStartup Lib "wsock32" _
(ByVal wVersionRequired As Long, _

Public Declare Function WSACleanup Lib "wsock32" () As Long

Public Function SocketsInitialize() As Boolean

Dim success As Long

SocketsInitialize = WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS

End Function

Public Sub SocketsCleanup()

If WSACleanup() <> 0 Then
MsgBox "Windows Sockets error occurred in Cleanup.", vbExclamation
End If

End Sub

Public Function GetIPFromHostName(ByVal sHostName As String) As String

'converts a host name to an IP address.

Dim nbytes As Long
Dim ptrHosent As Long
Dim ptrName As Long
Dim ptrAddress As Long
Dim ptrIPAddress As Long
Dim sAddress As String

sAddress = Space$(4)

ptrHosent = gethostbyname(sHostName & vbNullChar)

If ptrHosent <> 0 Then
ptrName = ptrHosent

'assign pointer addresses and offset

'The Address is offset 12 bytes from the start of
'the HOSENT structure. Note: Here we are retrieving
'only the first address returned. To return more than
'one, define sAddress as a string array and loop through
'the 4-byte ptrIPAddress members returned. The last
'item is a terminating null. All addresses are returned
'in network byte order.
ptrAddress = ptrHosent + 12

'get the IP address
CopyMemory ptrName, ByVal ptrName, 4
CopyMemory ptrAddress, ByVal ptrAddress, 4
CopyMemory ptrIPAddress, ByVal ptrAddress, 4
CopyMemory ByVal sAddress, ByVal ptrIPAddress, 4

GetIPFromHostName = IPToText(sAddress)

End If

End Function

Private Function IPToText(ByVal IPAddress As String) As String
On Error GoTo errHandler
MsgBox CStr(Asc(IPAddress))
MsgBox CStr(Asc(Mid(IPAddress, 2, 1)))
MsgBox CStr(Asc(Mid(IPAddress, 3, 1)))
MsgBox CStr(Asc(Mid(IPAddress, 4, 1)))

IPToText = CStr(Asc(IPAddress)) & "." & _
CStr(Asc(Mid$(IPAddress, 2, 1))) & "." & _
CStr(Asc(Mid$(IPAddress, 3, 1))) & "." & _
CStr(Asc(Mid$(IPAddress, 4, 1)))

Exit Function
MsgBox "Error Getting IP", vbCritical, "StorageOne"

End Function

Sub Main()

Dim sHostName As String
Dim sip As String
If SocketsInitialize() Then

'pass the host address to the function
sHostName = ""
sip = GetIPFromHostName(sHostName)
MsgBox sip


MsgBox "Windows Sockets for 32 bit Windows " & _
"is not successfully responding."

End If

end Sub
thanking you

How To Know The User ( Or The Hostname Or IP ) Who Changed The File Or Folder ?
To watch a file on a netwark shared drive I used the FileSystemWatcher

and I get the change type and the full path

but how could I know the user ( or the hostname or IP ) who changed the file or folder ?

I think that the EventLog could work but I don't kow how >>

Edited by - abd_farra on 7/16/2007 7:54:36 AM

Resolve DNS/RAM
Anyone have code to resolve a domain name into an ip address and place it in a textbox or something? Also is there a very simple script to get the ram amount/useage of the computer?

How Do I Resolve This??
Hey folks,

I shall be please if you guys can figure out my problem.
I have created using vb6 enabling user to enter a specific date.

Based on the date enter by the user, the program would need to trace the folder from C:Folder1...with that specific date entered.(Folder1 consists of many date folders).
Later it will copy these date folder and its contents into a new destination folder for backup purposes.


Date_Entered = dd/mm/yy

Copy C:Folder1Date_Entered*.* to D:Folder1Date_Entered

pls help. thanks in advance!

I'm fairly new to the art of VB programming - I've been doing it for just over a month now, non-stop. In this time, I've done databases, writing/reading/creating text files (and other stuff), password systems (based on hard drive serials) copy protection etc... I really love the language, and enjoy programming greatly. At the moment I'm doing some paid work, and have committed my first major blunder:

I have a farily good graphics card, and so I always run at (about) 1152x854 (or whatever it is). You can probably guess what's coming next. Most of my forms are getting on for full screen, but my project needs to be compatible with 800x600 set-ups... D'oh! Luckily, I haven't written any routines in the code that re-size or create forms or controls, so I have resigned myself to having to redraw everything in 800x600 mode. This would be a long job, and so I'm looking for cunning alternatives. Any ideas anyone?

I did think about writing a routine that gets the screen height and does some maths to re-scale everything. This would involve the controls object with a for each loop, set up as a public sub, using me.controls as the "in" part:

Public Sub ResizeAll()
Dim X as Control

For Each X in Me.Contols
{re-sizing code}
Next X

End Sub

Would this do the trick? The only problem is that I have loads of pictures - for my buttons and in picture boxes and image boxes. These would all have to be re-drawn in my art package, right?

If anyone could help me out, I'd be most gratetful. I'm not sure I could offer much in return, being quite inexperienced, but I'd have a go!

The moral of the story (my new RESOLVE!): Always design in 800x600!

Look forward to hearing from you - even if it is to laugh at me!


Can Any One Resolve IT ????

I am computer engineer and I am facing some problems in programming MS OutLook using Visual Basic 6.0 .
My problem is the following:
I am making a DLL for Microsoft Outlook 2000 which adds a Button to the standard toolbar and on Click it should do different things. One thing is determining the current opened message in the inbox, i.e. controlling -programmatically- the current opened message, in details : the message that the user is seeing opened in a window ..
This is the source code related to the problem :

Code:Dim i As Integer
Dim Continue As Boolean
Dim myfolder As Outlook.MAPIFolder
Public WithEvents MyItem As Outlook.MailItem

Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
  MsgBox "...My button is Active.."
  If MyItem Is Nothing Then
                For i = 1 To myfolder.Items.Count
                     If (Continue) Then
                             MsgBox " You passed continue variable..."
                             Set MyItem = myfolder.Items(i)
                     End If
            Set MyItem = Nothing
 End If
 Continue = True
 Set MyItem = Nothing
 End Sub

Private Sub MyItem_Read()
        Continue = False
        MsgBox "You entered MyItem_Read()"
        ' MsgBox "This is the body of current opened message :" & i & " " & MyItem.Body
        Set MyItem = Nothing
End Sub

As you see, I made a loop for all messages in Outlook inbox setting -every time (every i) - MyItem as the message so that when Myitem is the current opened message , the MyItem_Read event will fire and I can controll the current opened message...i.e. getting it's index, body, ...etc.
What makes me made is the strange behaviour of this algorithm...few times give correct results and often inaccurate results.
I'll appreciate any contribution because I'm not able to figure out a solution.
I also wait another opinions about finding different algorithm for doing that.

Thanks in Advance

Resolve Ip From Novell Name
Hey. I'm programming a chat program for my school. I log on to the novell network using a username like MartJern29. When one for example use Net Send or Ping in Cmd you use that name (martjern29). But when pinging from vb you can not use that name. I want to ping a user and see if he/she is online. So how do i ping a novell username? or how do i resolve the ip to that computer in use, so i can ping that?
Any helpt will be great


A Few Issues To Resolve
OK. I have a few issues I am trying to resolve in a workbook application I am improving. First of all, I would like to know how I would go about determining, through a VBA function, whether a cell is hidden or not. I have set up an editor so that users can easily edit hidden information, without messing up the whole workbook. Some of the cells that will be edited are actually hidden, and others are simply on hidden worksheets. Of course, I unhide and unprotect all of my sheets upon initializing the editor, but I don't know how to determine whether or not a cell is hidden. Obviously, if it is hidden, I will want to unhide it, and then re-hide it when the userform is closed. If it's not hidden, I obviously don't want to hide it when I'm finished.

Second issue - In the editor that I've set up, I have two options on how to edit the information. The user can either use the built-in text box to edit the information, or they can click a button to go directly to the cell containing the information. Unfortunately, the application.goto command does not seem to want to work within my userform. I have set up a variable to gather the name of the cell that the user will be editing, and I have then added an application.goto command to go to that variable. I have checked the code in break mode, and the variable is being stored correctly, and is being plugged into the command correctly (if I hold my mouse cursor over the goto command, it shows up correctly). However, when I try to execute the command, I get the following error:


Run-time error '1004':

Method 'Goto' of object '_Application' failed.

This is the offending line of code:

Application.Goto Reference:=strEditRange
where strEditRange is a string variable I've gathered from another cell within my workbook (I keep all of my cell names stored in a particular row within my workbook so that they're easy to reference through code).

As I said, the variable is being stored properly, but the goto command is not working. Is it not possible to use a goto command within a userform? Or is there some other way of doing it? Does anyone see what my problem is? I know the goto command works within my workbook, as I use it in quite a few of my subroutines successfully, but for some reason it just refuses to work in this userform.

TNS Could Not Resolve Service Name

I have a problem while connecting to a database from my VB application.

Application connects to the same database twice. With the first connection object it connects fine but with the second connection object it gives an error "TNS Could not resolve service name".

can any one plz help me.

thanks in advance

[need To Resolve] Listbox
Hello guys,

I need to resolve with the listbox to make sure that i can adding up on the listview. It is possible to make the listview to have a web access to update the info?? And it is possible to have a icons with the the highlight colour, context menu and the background on the listview??????

Help would appreciate thanks

Need Help WithEvents[RESOLVE]
Handling an Object's Events...
"An object that raises events is called an event source. To handle the events raised by an event source, you can declare a variable of the object's class using the WithEvents keyword."

I would like to handle a click event raised by an event source such as a Command Button...need help

Private WithEvents mBack As CommandButton

[resolve]any Body Please Help?
basically, I have data input screen and save button on the form
when I click the "save" command button for the first time after my application starts up, it always runs o.k, but if I didn't exit the application completly and click save button again, the error message shows " object variable or with block variable not set" the highlighted line is below

it looks like I couldn't click the save button more than once unless I completely exit the application and then run again


private Sub cmdSaveExcel_Click()

Dim xl As Object 'Open Excel & create workbook/worksheet
Dim xlBook As Object, xlSheet As Object
Set xl = CreateObject("Excel.Application")
Set xlBook = xl.Workbooks.Open(App.Path & "ook1.xls")
Set xlSheet = xlBook.Worksheets.Add

'add id
Selection.ColorIndex = 53
xlSheet.Range("A1") = STR_ID

end sub

SQL Enquiry (resolve)
how do i (or can i)record the number of rows that exist with a column of same value.

Resolve Path...
I am trying to scan through a bunch of .vbp files, and get the paths of the references. Some of them appear like



Is there an API or something that will translate that into the absolute path of the file?

Is This Possible...Can Somebody Resolve(** Resolved**)
I have two text boxes on a form and I'm typing in one of them.. Iwant to send the same or different character to the other text box on every key press in the first text box basing on some conditions... How can I do this? I need to send a value to the other text box for every key press in the first one. I dont want to use OtherTxtbox.text=OtherTxtbox.text & "something"...please guide me... thank you

VB.NET Speed &gt; Let's Resolve It Once And For All
Well, the verdict is in!

I just came back from VisualStudio.NET conference in Toronto and I can tell you with a 100% of accuracy that ANY .NET language (C#, VB, J#) will have exactly the same performance.

The reason is that all those languages will be compiled into IL (intermediate language) which IS IDENTICAL for all the NET languages.

More, even non-Microsoft laguages that are CLR (common language runtime) compatible will be treated the same way and can be used on the net framework.

Can You Resolve This Asp Problem ??

I have a asp file that help me with uploading files via web.

The asp works fine, make its job.

But here is a proble:

I only can upload files to any directory in my web server that not be "C:InetPubWWWRoot" (the home directory of my web).

If I try to uploading a file into the "C:InetPubWWWRoot", a error appear: "Permision Denied."

I put into the asp a Scripting.FileSystemObject that copies the uploaded file to the "C:InetPubWWWRoot", but the result is the same (Permision Denied).

How I do to upload files into my home directory ??????

Thanks !!

How Do You Resolve This Problem?
Hi Everyone,

How do you resolve this error in VBScript?

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'DRIVER={Microsoft Ac'
/TATQSAA/ASP/Post.asp, line 24

I would appreciate any help. Thanks.

Resolve And IP Number
i have this "" can i resolve the ip for it???
like the ping in DOS

Resolve IP Address, Really Need Help...
Ok, I asked this before, but I didn't get a very good answer, (well sorta)... Anyways, I was wondering if there was a way to resolve the hostname of a computer or server into an IP address, but without using WinsockAPI or other junk that for some reason doesn't work... Is there other functions that I could invoke other than 'gethostbyname' from the 'wsock32.dll' file that would allow me to resolve an IP address? Is there a way to do it without using API at all?

Resolve Host Name And IP
Is there a way to get the host name given an ip ? I have the code to get the IP if given host name, now i need vice versa ... Can anyone help me ?

P.S. - If u have 2 ways, post both ... Winsock is good, API is just as good =)

Copyright 2005-08, All rights reserved