• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • Last Modified:

Finding the external IPnumber in VB6

Since the provider once in a while changes my external IP number I look for a way to "find"  in a vb6 function/sub to
"read"  my at that moment active external Ip adres.
0
BIAPRO
Asked:
BIAPRO
  • 7
  • 5
  • 2
1 Solution
 
jakethecatukCommented:
there are plenty of web sites that you can visit that will tell you the IP address you have come from (www.iptools.com being one).

you will probably need to write a function that browses to a particular website and parse the returning data to find your IP.
0
 
BIAPROAuthor Commented:
1.) offcourse , that we do now for years,
2.) thats why this request was placed, how to do that in vb6
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BIAPROAuthor Commented:
Tried that one gets back with errror and this:
?STR
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>404 - File or directory not found.</h2>
  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
 </fieldset></div>
</div>
</body>
</html>
0
 
jakethecatukCommented:
The link or the code snippet?
0
 
BIAPROAuthor Commented:
this code from the link

Option Explicit
' Add Microsoft Internet Transfer Control , i did

Public pubIPA As String, pos1 As Long, pos2 As Long, str As String
     
Private Sub Form_Load()
    str = netKK.OpenURL("http://vbnet.mvps.org/resources/tools/getpublicip.shtml", icString)
    pos1 = InStr(str, "var ip =")
    pos1 = InStr(pos1 + 1, str, "'", vbTextCompare) + 1
    pos2 = InStr(pos1 + 1, str, "'", vbTextCompare)
    pubIPA = Mid$(str, pos1, pos2 - pos1)
    MsgBox pubIPA, vbInformation
    Unload Me
End Sub
0
 
BIAPROAuthor Commented:
the link ("http://vbnet.mvps.org/resources/tools/getpublicip.shtml",
gives same error in explorer
0
 
jakethecatukCommented:
forgive me for being a bit blunt - but don't you know how to use Google???

Try 'get external IP vb6' in Google and see what comes back - you'll be amazed!
0
 
jakethecatukCommented:
0
 
BIAPROAuthor Commented:
that I saw ,  offcourse we use and are happy with google,
I did/do use this piece off code

Dim MyStaticIP As String
MyStaticIP = netKK.OpenURL("http://www.myipnumber.com/")
Debug.Print MyStaticIP

But for this http adresses i got something back wich is long html code like below,
and was just looking for a smart way to extract the ip number
this I get
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>

<HEAD>
<TITLE>
What is my IP number - my IP address - MyIpNumber.com
</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="keywords" CONTENT="What is my IP number, my IP address, My IP Number, MyIpNumber.com">
<META NAME="description" CONTENT="What is my IP number? MyIpNumber.com finds your IP address and gives information on IP numbers and addresses, DNS, and related technology.">
<META NAME="Author" CONTENT="MyIpNumber.com What is my IP number">
<META NAME="Copyright" CONTENT="&copy; 1999-2011&nbsp; MyIpNumber.com What is my IP number">
<LINK rel='stylesheet' type='text/css' href='infostyle.css'>
</HEAD>

<BODY  LEFTMARGIN="10" TOPMARGIN="10" MARGINWIDTH="10" MARGINHEIGHT="10">

<TABLE BORDER="1" BORDERCOLOR="#008000" CELLSPACING="0" CELLPADDING="10" ALIGN="CENTER" WIDTH="100%" BGCOLOR="#FFFFFF">

<TR><TD>
<!-- set min window width -->
<img src="images/transparent.gif" width="700" height="1"><br>


<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr height="5"><td></td></tr>
<tr>
<td align="left">
<H1><A href="/">My IP Number</A></H1>
<H2>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;What is my IP number / IP address?</H2>
</td>
<TD ALIGN="center" WIDTH="100"><IMG SRC="images/bkmk.gif" WIDTH="75" HEIGHT="55" BORDER="0" ALT="Bookmark This Site"></TD>

</tr>
<tr height="8"><td></td></tr>
<tr height="1"><td colspan="3" bgcolor="#400000"></td></tr>
<tr height="12"><td></td></tr>
</table>



    <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
    <td width="175" valign="top">
    <table border="0"  cellspacing="0" cellpadding="0" align="center" width="100%">
<tr><td>
    <table border="0"  cellspacing="0" cellpadding="0" align="center" width="100%" bgcolor="#C0FFC0">
    <tr>
    <td align="left"><IMG SRC="images/circle_green_1x1.gif" width="15" height="15"></td>
    <td></td>
    <td align="right"><IMG SRC="images/circle_green_1x2.gif" width="15" height="15"></td>
    </tr>
    <tr height="10"><td></td></tr>

    <tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="/">Home</A></SPAN></td></tr>
<TR height="3"><TD colspan="2"></TD></TR><tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="about.asp">About</A></SPAN></td></tr>
<TR height="3"><TD colspan="2"></TD></TR><tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="sitemap.asp">Site map</A></SPAN></td></tr>
<TR height="3"><TD colspan="2"></TD></TR>
    <tr><td colspan="3"><b>&nbsp;<BR>More:</b></td></tr>

    <TR height="3"><TD colspan="2"></TD></TR><tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="http://www.originalgames.com" target="_blank">Original Games</A></SPAN></td></tr>
<TR height="3"><TD colspan="2"></TD></TR><tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="http://www.pointlesscalendar.com" target="_blank">Unusual Gifts</A></SPAN></td></tr>
<TR height="3"><TD colspan="2"></TD></TR><tr><td valign="top">&nbsp;&nbsp;&nbsp;<IMG SRC="images/blob.gif" width="9" height="9">&nbsp;&nbsp;</td><td colspan="2" style="text-indent:-8px; padding-left:8px;"><SPAN class="menulink"><A href="http://www.pointlesssites.com" target="_blank">Pointless Sites</A></SPAN></td></tr>

    <td align="left"><IMG SRC="images/circle_green_2x1.gif" width="15" height="15"></td>
    <td></td>
    <td align="right"><IMG SRC="images/circle_green_2x2.gif" width="15" height="15"></td>
    </tr>
    </table>
</td></tr>
<tr height="10"><td></td></tr>
</table>


    </td>
    <td width="20">&nbsp;</td>
    <td valign="top">
   
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD>
<H3>What is an IP number / IP address?</H3>
<P>
'IP' stands for Internet Protocol - it decribes the way information is sent and received
over the Internet. An IP number, or IP address, is a 32 bit number assigned to any
device that wishes to communicate over the Internet. Typically the IP address is represented as a
set of four numbers in the range 0-255 - the address is usually written as these four numbers
separated by dots. It can also be shown as one big number in decimal or hexadecimal.
</P>
<H3>What is my IP number?</H3>
<P>
The IP number of this machine is:
</P>
<P align="center"><FONT size="7" color="#D00000"><B>
77.167.58.197
</B></FONT></P>

<P>
This number can also be represented as <font size="3" color="#D00000"><b>1302802529</b></font> (32 bit decimal number)
or <font size="3" color="#D00000"><b>0x4DA73061</b></font> (32 bit hexadecimal number).
</P>

<P>
(Note that if you are part of an internal network then this is the address of your local server, the
machine which is connected to the external internet.)
</P>
<H3>How are IP addresses used?</H3>
<P>
Whenever data is to be transmitted to a particular machine, it is broken up into chunks, or
<EM>packets</EM>, each of which is tagged with the IP address of the destination machine. Each packet
is transmitted separately, and will not necessarily follow the same route through the network
as the other packets that make up the whole message. It is quite possible that the packets will
arrive out of sequence, or with errors. Some may not even arrive at all.
</P>
<P>
On receipt the packets are automatically reassembled into the correct sequence so as to
reconstruct the original data;
if there are any errors or missing packets then they are requested to be sent again.
</P>
<H3>How are IP Addresses Assigned?</H3>
<P>IP addresses are hierarchical in nature - that is to say, one part of the address will specify
broadly in which region of the network the destination can be found, with subsequent parts of the
address providing more specific information about the location of the target device within that
region. Consequently the allocation of addresses needs to be carefully managed, in order to
maintain this hierarchy.
</P>
<P>
The allocation is overseen by the <EM>Internet Assigned Numbers Authority</EM> (IANA) and <EM>Regional
Internet Registries</EM> (RIRs), who maintain a publicly accessible database called WHOIS, relating
IP addresses to locations in the network.
</P>
<H3>What is DNS?</H3>
<P>
Most Internet users prefer to use addresses which are more meaningful than a sequence of numbers -
for example 'www.microsoft.com' instead of '207.46.199.30'. The translation from the textual
domain name to the numeric IP address is performed by certain machines on the internet, known
as 'Domain Name Servers'. Every computer that wants to be able to use domain names needs to know
the IP address of at least one Domain Name Server - it contacts this server any time it needs to
translate a domain name to an IP address. The server can either reply immediately with the IP address
if it knows it, or it can forward the request to another server which may be in a better position
to provide the information. When the translation is successfully performed, the server will  
keep a copy of, or cache, the address so that it can answer the request more rapidly the next time it is asked.
</P>
<P>
Domain names are resolved starting with the final part, the Top Level Domain (e.g. '.com', or '.de').
Every Domain Name Server knows the locations of certain machines known as Root Servers,
which are able to indicate where to find a machine that can handle the particular Top Level Domain.
The remainder of the domain name is then sent to this machine, which knows where to locate servers that
can deal with the next level in the domain name, and so on until the first part of the name is reached
(e.g. 'www'). At this point a full IP address can be returned through the various servers, back to the
machine which originated the translation request.
</P>
<P>
Each machine along the return journey will keep a cached copy of the IP address and domain name, so that if
asked for the same address in the near future it can respond immediately without having to contact
any other machines. This speeds up general operation of the network, although it does mean that if
the IP address for a particular domain name is changed at any time, it can take a while -
sometimes several days - for that change
to be propagated through the network. Until the change is propagated, the name servers will continue to
report the old (cached) IP address.
</P>
</TD>
</TR>
</TABLE>



    </td>
    <td width="20">&nbsp;</td>
    </tr>

    <TR><TD colspan="3">
    <DIV id="footer">
    <P>
    <A href="mailto:?subject=www.myipnumber.com &body=Take a look at this site">Tell a friend</A> about MyIpNumber.com&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
    <A href="about.asp">About</A> this site&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;
    <A href="sitemap.asp">Sitemap</A>
    </P>
    </DIV>
    </TD></TR>

    </table>

</TD></TR>
</TABLE>
<P ALIGN="CENTER">
<span class="small">&copy; 2002-2011&nbsp;MyIpNumber.com</span></P>
</BODY>
</HTML>

 5040




0
 
KarenAnalyst programmerCommented:
whatismyip.com has a special page for this
see http://forum.whatismyip.com/f14/our-automation-rules-t241/

so you should be able to just call
Dim MyStaticIP As String
MyStaticIP = netKK.OpenURL("http://www.whatismyip.com/automation/n09230945.asp")
Debug.Print MyStaticIP
0
 
BIAPROAuthor Commented:
this small code does it perfect! thanks
0
 
KarenAnalyst programmerCommented:
I'm glad I could help you :)
0
 
BIAPROAuthor Commented:
all vbexperts are great helpers,  as an old dos programmer (from the old days I even paid once Billy's lunch in Palo Alto,) and dispite  my age,   switched to windows some years ago, it means in support a lot to me!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now