|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
From Delphi to VBCan anybody assist to translate this for me, just moving over from delphi
function IntToIp(Address: LongWord): string; begin Result := Format('%d.%d.%d.%d', [ Address shr 24 and $ff, Address shr 16 and $ff, Address shr 8 and $ff, Address shr 0 and $ff]); end; cheers Henry Hello Henry,
You can easily use the IPAddress class (In System.Net namesapce) for this... Dim tAddressLong as Int64 = (YOUR INT64 ADDERSS HERE) Dim tAddress as IPAddress=New IPAddress(tAddressLong) tAddress.ToString() will give you the dotted format. Note that the IPAddress ctor expects tAddressLong to be in network byte order (Big Endian). If your tAddressLong is in Little Endian byte order then the IPAddress class provides funcions for converting it. If you really wanna write yer own then you want to use the bit shifting operators ( << for shift-left, and >> for shift-right ) -Boo Show quoteHide quote > Can anybody assist to translate this for me, just moving over from > delphi > > function IntToIp(Address: LongWord): string; > begin > Result := Format('%d.%d.%d.%d', [ > Address shr 24 and $ff, > Address shr 16 and $ff, > Address shr 8 and $ff, > Address shr 0 and $ff]); > end; > cheers > Henry > If you really wanna write yer own then you want to use the bit shifting I absolutlly don't want to do this myself if there's an existing method for > operators it somewhere, I need the first IP Address in the subnet of a IP address given a subnet mask eg subnet mask is given 255.255.255.240, that results in 16 subnets with 14 IP addresses each. I need to identify from which subnet I receive a client connection from, eg any IP address from 192.169.1.1 to 192.169.1.14 comes from subnet 192.169.1.0 (first IP address is 192.169.1.1) I need result 192.169.1.0 any IP address from 192.169.1.17 to 192.169.1.30 comes from subnet 192.169.1.16 (first IP address is 192.169.1.17) I need result 192.169.1.16 any IP address from 192.169.1.13 to 192.169.1.46 comes from subnet 192.169.1.32 (first IP address is 192.169.1.33) I need result 192.169.1.32 and so forth Do you understand? Is there an easy way to get that address? cheers Henry Hello Henry,
Nope, I don't understand. A subnet is just a bitmask that partitions off the network portion from the host portion of an address.. as such, your example subnets dont make any sense. I had originally thought your function was trying to convert the integer representation of an IP address into the dotted notation. Anyhow, since you seem to understand what yer doing just use the bit shifting operators and you can convert your old Deli code. -Boo Show quoteHide quote >> If you really wanna write yer own then you want to use the bit >> shifting operators >> > I absolutlly don't want to do this myself if there's an existing > method for it somewhere, > > I need the first IP Address in the subnet of a IP address given a > subnet mask > > eg > > subnet mask is given 255.255.255.240, that results in 16 subnets with > 14 IP addresses each. > > I need to identify from which subnet I receive a client connection > from, eg > > any IP address from 192.169.1.1 to 192.169.1.14 comes from subnet > 192.169.1.0 (first IP address is 192.169.1.1) > I need result 192.169.1.0 > any IP address from 192.169.1.17 to 192.169.1.30 comes from subnet > 192.169.1.16 (first IP address is 192.169.1.17) > I need result 192.169.1.16 > any IP address from 192.169.1.13 to 192.169.1.46 comes from subnet > 192.169.1.32 (first IP address is 192.169.1.33) > I need result 192.169.1.32 > and so forth > > Do you understand? > > Is there an easy way to get that address? > > cheers > Henry
Undefined function 'InStrRev' in expression.
last ditch attempt to try and get this working error in the update Array Problems - still cant get something set up right. Dll fails to register Streamreader doesn't read the line properly identity /autonumber drives me nuts Click and Double click events are not fired in listview component in VB.NET WithEvents code in module cannot change textbox on main form Reading XML file getting error |
|||||||||||||||||||||||