Integer overflow in vb.net 2005

adv

New member
Joined
Oct 8, 2007
Messages
1
Programming Experience
Beginner
Hi all,
I am pretty new to vb.net and as such facing a pretty simple.

I have an application which is finally going to call a function defined in a dll.
The function declares a variable of type unsigned long

int funct(unsigned long lvar);

The size of unsigned long on my machine in 4 bytes.

Now in vb.net (I am using VS 2005 express) app, I have declared a variable(lvar) of type int32.

In the vb.net app, I am giving the variable (lvar) a value equal to "He443ea12"
(decimal value = 3829656082 )

This value is greater than the max value of the type int32.( max value = 2,147,483,647)


After this I am calling the function funct(lvar), defined in the dll, in the usual way.

Everything is working fine with the function doing it's intended purpose.

However, I read in some article that vb.net raises an exception as soon as it detects the integer getting overflowed. In my app, integer overflow is clearly taking place ,but still I am not getting any exception from my app.

Can somebody please point out where I am wrong?

As a side note, this is how I am giving a large value to the varible in the vb.net app

dim lvar as int32
Dim sVar As String = "9705a27d"
lvar = Int32.Parse(sVar.Trim(), Globalization.NumberStyles.HexNumber)


PS I cannot use uint32 in my app so as to make the app CLS compliant. Also I cannot use Int64 as
the variable in my dll is of 4 bytes and hence it's usage is giving me the stack imbalance problem.

Thanks
 
Ps; using a DLL in your app, that makes use of datataypes that are not CLS compliant themselves, would naturally infer that your app cannot be CLS compliant also, if it is to be compliant with those functions.. no?
 
Back
Top