Results 1 to 6 of 6

Thread: [2005] IP Finder

  1. #1

    Thread Starter
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    [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.

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2005] IP Finder

    shouldn't this be in the codebank?
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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)

  4. #4

    Thread Starter
    Hyperactive Member knxrb's Avatar
    Join Date
    Jul 2007
    Location
    United Kingdom
    Posts
    321

    Re: [2005] IP Finder

    i'm only tryin to help people. sorry if its complicated, but at least it works!

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2005] IP Finder

    Quote 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
  •  



Click Here to Expand Forum to Full Width