Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted
UInt32 is not CLR-compliant and should not be used. Instead, Int64 (Long) should be used. However, if you have no control over it:
Dim num As UInt32 = Convert.ToUInt32(<your number>)

That should do the trick.

  • *Experts*
Posted

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

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...