By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

integer ->System.Unit32

P: n/a
Dear all,
how do I convert a .NET integer into System.Uint32 (needed to call external
function)
Thanks,
Boni
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Convert.ToUint32

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Boni" <oilia@nospam> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Dear all,
how do I convert a .NET integer into System.Uint32 (needed to call
external function)
Thanks,
Boni

Nov 21 '05 #2

P: n/a


"Boni" <oilia@nospam> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
:
: Dear all,
: how do I convert a .NET integer into System.Uint32 (needed to call
: external function)
: Thanks,
: Boni
I assume by 'external function' you mean a function in a .DLL that isn't
part of dot net (e.g.: a windows API call or similar) in which case, the
function is expecting an unsigned 32 bit integer as a parameter and / or
returns the same. Correct?
This isn't my strong suit but I believe you can simply specify an
integer (System.Int32) and use it whereever the funtion specifies. The
external function shouldn't care if vb considers the value signed or
not- only that it has the correct number of bits. The problem in vb is
it doesn't support using unsigned integer values. It only supports
signed integers (System.Int32).
If you need to assign the value of the integer to some value greater
than 2147483647 (the positive upper limit of an Int32 value) before
passing to the function, you can use hex notation. For example, if you
need to supply the value 3000000000, you could use the notation
&HB2D05E00. Beyond that however, you are limited to treating the value
as signed.
I guess what I'm saying is, I believe you can pass Int32 values in and
out of external functions that expect unsigned 32 bit integers without
issue, but you cannot manipulate them in your code as such - your system
will always see them as being signed. (Note, C# does support unsigned
integers and may be more suited for your purposes in this instance).
Ralf
Nov 21 '05 #3

P: n/a
Hi Boni,

Use Convert.ToUInt32().

Roman
"Boni" <oilia@nospam> сообщил/сообщила в новостях следующее:
news:ua**************@TK2MSFTNGP12.phx.gbl...
Dear all,
how do I convert a .NET integer into System.Uint32 (needed to call external function)
Thanks,
Boni

Nov 21 '05 #4

P: n/a
"Boni" <oilia@nospam> schrieb:
how do I convert a .NET integer into System.Uint32 (needed to call
external function)


In VB.NET 2002/2003 you can use 'Convert.UInt32'. VB 2005 natively supports
unsigned numeric types.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

P: n/a
VB.NET 2005 fully supports unsigned integer types. If you need it in
production before 2005 is released then use _AnonCoward's suggestion.
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Clear VB: Cleans up outdated VB.NET code
Instant C#: Converts from VB.NET to C#
Instant VB: Converts from C# to VB.NET
Instant J#: Converts from VB.NET to J#

"Boni" wrote:
Dear all,
how do I convert a .NET integer into System.Uint32 (needed to call external
function)
Thanks,
Boni

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.