Chris,
In addition to the other comments.
The "problem" is that C# by default does not raise OverflowExceptions, while
by default VB does.
In VB 2005 you can use "Project Properties - Compile - Advanced Compile
Options - Remove integer overflow checks" to get the following assignment to
work:
Dim someUint As UInt32 = callSomeFunction()
Dim someInt As Integer = CType(someUint, Integer)
VB 2002 & 2003 don't support UInt32, so I'm not expecting the overflow check
option to help you much there!
Of course changing the "Remove integer overflow checks" may cause adverse
effects elsewhere in your code...
FWIW: "Project Properties - Build - Advanced Build Settings - Check for
arithmetic overflow/underflow" is the corresponding option in C#. For
example changing the "Check for arithmetic overflow/underflow" option will
cause your original code to fail, just as VB does!
uint someUint = callSomeFunction();
int someInt = (int)someUint;
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Chris Botha" <ch*************@hotmail.com> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
| Here is the C# equivalent:
|
| uint someUint = callSomeFunction();
| int someInt = (int)someUint;
|
| After the function call the value of someUint is Hex FFFFFFDB (or then
| 4294967259 as noted by Matthew).
| After casting it to an integer in C#, the second statement in my example,
| the value of the integer is -37, which is what I want.
|
| I am trying to achieve the same in VB.
|
| Thanks again.
|
|
| "Armin Zingler" <az*******@freenet.de> wrote in message
| news:eD**************@TK2MSFTNGP10.phx.gbl...
| > "Chris Botha" <ch*************@hotmail.com> schrieb
| >> Hi guys, thanks for the answers, but I know what the problem is, and
| >> I am looking for a workaround in VB. I can do it in C#, but this is
| >> a VB project :-(
| >
| >
| > *What* do you want to do? Give us some context.
| >
| > Armin
|
|