Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constant expression not representable in type 'UInteger'

If I run the following code in C# then it runs fine

UInt32 a
a = 0x9E3779B9

But when I run the same code in VB.Net then it gives me error "Constant expression not representable in type 'UInteger'"

Dim a As UInt32
a = &H9E3779B9
like image 845
Ali Avatar asked Nov 26 '25 06:11

Ali


2 Answers

Just put UI at the end

a = &H9E3779B9UI

Check this link

From MSDN

You can follow a prefixed literal with a literal type character. The following example shows this.

Dim counter As Short = &H8000S
Dim flags As UShort = &H8000US
like image 169
Habib Avatar answered Nov 27 '25 18:11

Habib


I think you can solve you problem by viewing this link see the workarounds section in this link

Just add "UI" to the end of the literal:

      Dim x as UInteger = &HF2894233UI

Otherwise &H returns a signed Integer

like image 34
Waqar Avatar answered Nov 27 '25 19:11

Waqar