469,323 Members | 1,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Using Uint in VB .NET

C# allows one to specify a constant with a type of uint, so you could have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?

--
http://www.standards.com/; See Howard Kaikow's web site.
Nov 21 '05 #1
6 12355
"Howard Kaikow" <ka****@standards.com> schrieb:
C# allows one to specify a constant with a type of uint, so you could
have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?


Currently that's not supported by VB.NET because VB.NET doesn't "natively"
support unsigned types (notice that the unsigned types are not CLS
compliant).

Untested:

\\\
Private ReadOnly varname As UInt32 = _
Convert.ToUInt32(&HFFFFFFF0)
///

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

Nov 21 '05 #2
I had tried something like that.

Error returned is "Value was either too large or too small for a UInt32."

The only things that "work" are

Private ReadOnly varname As Integer = &HFFFFFFF0
Const zz As Integer = &HFFFFFFF0

--
http://www.standards.com/; See Howard Kaikow's web site.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eH**************@tk2msftngp13.phx.gbl...
"Howard Kaikow" <ka****@standards.com> schrieb:
C# allows one to specify a constant with a type of uint, so you could
have,
say:

private const uint varname = 0xFFFFFFF0

How does one port such statements to VB .NET?


Currently that's not supported by VB.NET because VB.NET doesn't "natively"
support unsigned types (notice that the unsigned types are not CLS
compliant).

Untested:

\\\
Private ReadOnly varname As UInt32 = _
Convert.ToUInt32(&HFFFFFFF0)
///

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

Nov 21 '05 #3
Even if you get any of these variations to actually compile, it is still of
little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.

Gerald
Nov 21 '05 #4
that should read...
You can "NOT" add, subtract, etc...

"Gerald Hernandez" <Cablewizard@sp*********@Yahoo.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still of little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.

Gerald

Nov 21 '05 #5
"Gerald Hernandez" <Cablewizard@sp*********@Yahoo.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still of little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are
no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.


I understood that.

Fer now, I'm just passing a constant to a sub/function, so I can get by
cheating with Integer.
Nov 21 '05 #6

"Howard Kaikow" <ka****@standards.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
"Gerald Hernandez" <Cablewizard@sp*********@Yahoo.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
Even if you get any of these variations to actually compile, it is still

of
little use.
While VB.Net (pre 2005) does allow you to declare Unsigned Ints, there are no operators.
You can add, subtract, etc. not even within the same data type.
Even simple compares will choke in many cases.


I understood that.

Fer now, I'm just passing a constant to a sub/function, so I can get by
cheating with Integer.


As long as you resign yourself to using bit-wise operations only, then this
is your best bet. It is what I do, and it works quite well. If you need that
extra top bit, then the best thing to do is work with a Long (Int64).
Sometimes that extra bit is all you really need, it seems a shame to waste
another 32. But hopefully this will be solved with VB 2005.

Gerald
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by pvdm | last post: by
2 posts views Thread by rawCoder | last post: by
5 posts views Thread by Ken | last post: by
2 posts views Thread by mmmobasher | last post: by
47 posts views Thread by Bonj | last post: by
9 posts views Thread by Sarath | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.