473,471 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

From Delphi to VB

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
Jun 14 '06 #1
3 2071
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
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

Jun 14 '06 #2
> 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
Jun 14 '06 #3
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
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

Jun 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shane | last post by:
Greetings, I've been trying to get PyRun_SimpleFile to work from Delphi without success, has any one done this? Doing it in C/C++ is trivial, but I need Delphi and I'm not a Delphi expert. ...
2
by: Huseyin Altun | last post by:
I have DLL written in Delphi 6. Its prototype is below: function EnumUserGroups(Proc: TEnumUserGroupProc; APtr: Pointer): LongInt; stdCall; I have declared it in c# like below: (VS 2003) ...
10
by: Arda Han | last post by:
I am migrating my some applications from Delphi to C#. But... Yes But I don't know C# professionally. I am using DLL in delphi like this : ..... const RFID_103_485IO = 'Cihaz.dll'; ...
6
by: David Lozzi | last post by:
Here is the proc: CREATE PROCEDURE . @CID as int, @Netname as nvarchar(25), @Return as int OUTPUT AS IF EXISTS (SELECT DISTINCT netname FROM computers WHERE CompanyID = @CID AND...
4
by: Three | last post by:
Hi there, I have to integrate a .Net application into a Delphi application somehow. The simplest method is to get the Delphi app to call a .Net console app, however it would be better for...
5
by: Just call me James | last post by:
Hi, Coming away from the luxury of the delphi IDE has been something of a shock. As a consequence I've become aware that maybe I need to spend some money on a python IDE. As a beginner I...
5
by: Dinesh Kumar | last post by:
Hi all I am using VB.NET for a Connector dll in Delphi client and some webservice . can you tell me how to handle pointers in Vb.net which are passed by delphi client as parameters in function...
8
by: Claus | last post by:
Hi all, I am new to C#, .NET and Visual Studio but I have been coding professionally for more than 10 years, so I am not a complete newbe :-) At my work we are now in the process of switching...
2
by: Larry Bates | last post by:
I have a rather large Python class that I've converted to a COM object. I can dispatch (using either Python or VB) and call the methods perfectly. Now a new client wants to call it from Delphi. ...
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.