Integer overflow in vb.net 2005

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2007
Posts: 2
Reputation: adv is an unknown quantity at this point 
Solved Threads: 0
adv adv is offline Offline
Newbie Poster

Integer overflow in vb.net 2005

 
0
  #1
Oct 8th, 2007
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?

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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 2
Reputation: adv is an unknown quantity at this point 
Solved Threads: 0
adv adv is offline Offline
Newbie Poster

Re: Integer overflow in vb.net 2005

 
0
  #2
Oct 8th, 2007
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)


Thanks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC