how to use UInt32???

baby_vb

Newcomer
Joined
Nov 3, 2003
Messages
9
Can someone please tell me how to use a UInt32 type and access and set its values? I'm trying to call a DLL method that has one of its parameters as a UInt32 type. The parameter is just the baud rate of a connection I'm setting up, so I want to set or hard code that value somewhere before it's called. But how do I pass the value in if the method is expecting a UInt32?

Thank you for helping
 
UInt32 is not CLR-compliant and should not be used. Instead, Int64 (Long) should be used. However, if you have no control over it:
Visual Basic:
Dim num As UInt32 = Convert.ToUInt32(<your number>)
That should do the trick.
 
Is the DLL called using DllImport or through a .NET or COM reference? If it's using DllImport, I'd bet you could define the parameter in VB.NET as Int32 and pass your value - technically an unsigned and signed int are the same except how math is performed. And since you're passing a baud rate, which is well within the signed int's range, you shouldn't have any problems.

-Nerseus
 
The DLL is called through a .NET reference. And I never did figure out why they defined a baud rate as an unsigned integer type, instead of regular old integer.


In any case, thanks VolteFace, your code worked great! :D
 
Back
Top