Using Uint in VB .NET

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

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?
 
Howard Kaikow said:
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)
///
 
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
 
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
 
Gerald Hernandez said:
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.
 
Howard Kaikow said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top