Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 16th, 2005, 08:43 AM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Michael Eaton
Default Learning VB 2k5. Cant convert to string error.

Hey guys, my first ever post!


I've looked around and i'm loving this website..

I decided i wanted to learn VisualBasic to help build an application to help me in my job, (i support web hosting clients). I've only even touched PHP/MySQL and some bash scripting. Nothing using OO(P).

I'm using the new Visual Basic 2005 Express Edition. Which is great, i love it. Nice clean design and works well.


Ok, on to my problem. This is/may be really basic. But i just cant fathom it out:


One of my daily tasks i find myself doing is looking up IP's from a hostname, and vice versa, now i know there are hundreds of apps/tools out there but i want my own, to work it the way I want it to work. Plus i want to learn anyway.


The code i have:

Code:
Private Sub Button1_Click(.... blah.. )

   Dim hostInfo As Net.IPHostEntry = GetHostEntry("domainname")
   MessageBox.Show(hostInfo)

End Sub

' The error:
' Value of type 'System.Net.IPHostEntry' cannot be converted 
' to 'String'.
Now i know this is wrong, and i know about why its wrong, but for the life of me i cannot figure a way around it. I have searched the internet but i only find ASP.Net examples and I dont think i could utilse any of the workarounds/solutions that are provided.

I hope that someone will take pity on me, and help me out. I also am very willing to read / research, so i dont mind if i get told to "RTFM" as long as you point me to the section i need, or at least give me a hint.

I want to thank anyone in advanced for helping me out.

Thanks.

Michael


PS: Wow, this turned out to be one hell of a post! :)

---------------------

Thanks for all your help P2P Wrox! (and its users)
 
Old November 16th, 2005, 02:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Dim hostinfo As IPHostEntry = Dns.Resolve("p2p.wrox.com")
Dim addressToGet As IPAddress
For Each addressToGet In hostinfo.AddressList
    Messagebox.Show(addressToGet.ToString)
Next
--------------------------------------------

J
 
Old November 16th, 2005, 03:28 PM
Registered User
 
Join Date: Nov 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Michael Eaton
Default

Sweet, Thanks!

Few more questions, I'm going to want to grab a few other records from dns too, such as a, ns, mx, ptr etc.. is there an easy way to do this?

Also any other tips / articles etc i'd be very grateful.


Thanks!

Michael

---------------------

Thanks for all your help P2P Wrox! (and its users)
 
Old November 16th, 2005, 04:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

This was based upon an example from MSDN and utilizes the DNS class in the System.Net namespace. You might want to look there. I haven't done specific queries on name servers to grab a, ns, etc. records - just hostname to IP resolution.

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert string to datetime in VB.net lisabb ASP.NET 2.0 Basics 3 June 19th, 2007 06:52 AM
VB.NET developer learning C# paulmarshall ASP.NET 2.0 Professional 1 February 27th, 2007 03:12 PM
New in .Net VB but learning datareader, access DB tjgrindsted ASP.NET 2.0 Basics 2 February 6th, 2007 08:49 PM
default(System.Type) does this exist in VB.NET 2k5 Peace2u ASP.NET 2.0 Basics 0 August 18th, 2006 06:51 AM
VB.NET: Convert String and append to Xml files toytoy Pro VB.NET 2002/2003 0 September 2nd, 2004 10:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.