VB.NET unsigned long alternative

  • Thread starter Thread starter saima ashraf
  • Start date Start date
S

saima ashraf

Hi,
I am desperately looking for the alternative of unsigned long in vb.net
CF.
I have already tried using the following with no luck:

-long
-double
-intptr
-system.uint34
-system.uint64
-Byte(4)


any help is welcome.
regards
Saima
 
ulong would be System.UInt64. Could you give us some more information on
what you try to achieve so we can help you further?
 
but an 'unsigned long' from C++ would translate to a uint in .NET or a
System.UInt32
 
Hi Saima,

System.UInt64 is the alternative but a lot of functionality for unsigned
types is not supported in VB. When I encounter this problem I either just
use a signed type or I convert it to do operations. For example:

Dim test1 As UInt64 = Convert.ToUInt64(10)
Dim test2 As UInt64 = Convert.ToUInt64(5)

' Have to convert to Int64 to use the + operator
Dim test3 As UInt64 = Convert.ToUInt64((Convert.ToInt64(test1) +
Convert.ToInt64(test2)))

Not pretty to look at or efficient but when going from native code or C# to
VB sometimes you have no choice.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
What actually i am trying to do is that I have a C++ dll .. whose
parameters take pointers to some structures. Now i do not have any
definition of these strutures so i can not redeclare them and create
objects of that type and send the object byref to the method from
VB.NET. So what i am told to do is that since C++ pointers are unsigned
long variables (4 bytes size)... i should try to send some object of
type unsigned long .Since ulong is not supported in VB.NET so i am
looking for the alternatives...
got any clues now for the possible solution?

I wonder y there are no unsigned types in VB.NET.

regards,
Saima.
 
Yes, system.UInt32 or better yet IntPtr. This will only work if the
parameter accepts NULLs and you can pass IntPtr.Zero

-Chris
 
Saima,

Use the IntPtr data type. A long in .NET is 8 bytes, not 4. The IntPtr
data type is designed for use as an opaque pointer, typically when calling
APIs or DLLs.

HTH,
Tom
 
Back
Top