Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert dotted quad to decimal in VB

Status
Not open for further replies.

lexx

Technical User
Nov 23, 2000
25
0
0
US
I have been hashing this out for several sleepless nights.. can some one help.

I want VB6 to convert the dotted quad IP to a decimal..

I know VB has no function for this....
 
Hi Lexx:

Not sure what you are looking for in the decimal. Can you give an example of a conversion that you are looking for?

For example, given 123.456.789.012, what decimal do you want to convert to?

Cassie
 
I ping a host URL and it returns the IP. but when I try to get the decimal conversion from the IP it is in reverse order..

Your IP: 123.456.789.012

After the decimal conversion it will be: 012.789.456.123
when converted back from the decimal form to the IP.

I tried the VB: StrReverse(Address)
Refresh

function, to reverse the string but it fails to return the decimal equivalent in proper order for the web browser.

 
I know why now.. inet_addr breaks dotted quad to a string and returns the byte return in lowest value from right to left instead of left to right.

230.79.58.64 = R to L yahoo.com IP backwards
197166914 = decimal " " "

I have to use the function ntohl( network to host long ) in order to return the IP to byte order left to right.

64.58.79.230 = L to R yahoo.com IP correct.
1077563366 = decimal " " "

Trying to use strReverse(address) to reverse the string 230.79.58.64 to 64.58.79.230 failed.

This is how it works for intel machines.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top