|
-
Sep 14th, 2007, 10:54 AM
#1
Thread Starter
Hyperactive Member
[2005] IP Finder
I've made an IP finder! I had a look on the web for 'get ip' code and I couldn't find any(that I understood); so I put some together and came up with my application 
Application:
[Link to compiled executable removed — Mod]
Code:
Code:
Imports System
Imports System.Net.Dns
Public Class Main
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim shostname As String
shostname = System.Net.Dns.GetHostName
Console.WriteLine("Your Machine Name = " & shostname)
Console.WriteLine("Your IP = " & GetIPAddress())
TextBox1.Text = shostname
txtip.Text = "" & GetIPAddress()
End Sub
Shared Function GetIPAddress() As String
Dim oAddr As System.Net.IPAddress
Dim sAddr As String
With System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName())
oAddr = New System.Net.IPAddress(.AddressList(0).Address)
sAddr = oAddr.ToString
End With
GetIPAddress = sAddr
End Function
End Class
Last edited by penagate; Sep 14th, 2007 at 02:17 PM.
-
Sep 14th, 2007, 11:26 AM
#2
Re: [2005] IP Finder
shouldn't this be in the codebank?
-
Sep 14th, 2007, 12:25 PM
#3
Re: [2005] IP Finder
You've made it unnecessarily complicated. Here is a much simplier version
Code:
Dim entry As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(Environment.MachineName)
Dim IPs As String = String.Empty
For Each IP As System.Net.IPAddress In entry.AddressList
IPs &= IP.ToString & " "
Next
MessageBox.Show(IPs)
-
Sep 14th, 2007, 01:56 PM
#4
Thread Starter
Hyperactive Member
Re: [2005] IP Finder
i'm only tryin to help people. sorry if its complicated, but at least it works!
-
Sep 14th, 2007, 02:17 PM
#5
Re: [2005] IP Finder
Sorry but we don't allow links to or attached compiled executables here. If you want however you're welcome to post your code snippets in the appropriate Codebank section.
-
Sep 14th, 2007, 02:27 PM
#6
Re: [2005] IP Finder
 Originally Posted by knxrb
i'm only tryin to help people. sorry if its complicated, but at least it works!
There are normally more than one way to slice an apple, and the same is true to programming. I'm NOT saying that your code won't work, I've only said it is more complicated than it should be. I know you're trying to share your knowledge with others here (and that's great), but like I said earlier, there are usually many ways to achive a same task and within those, some are better than the others. So I just want to show you a nother way of doing it with less code. Better? I don't know but shorter is for sure.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|