Overflow Error In Vb 6.0
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Visual Basic Reference Visual Basic Language Reference Error Messages Error Messages Overflow (Visual Basic Run-Time Error) Overflow (Visual Basic Run-Time Error) Overflow (Visual Basic Run-Time Error) '#ElseIf' must be preceded by a matching '#If' or '#ElseIf' '#Region' and '#End Region' statements are not valid within method bodies/multiline lambdas '
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VB6 overflow error with large integers up vote 13 down vote favorite 3 I am trying to set an integer value as such: Dim intID as integer intID = x * 10000 This works ok when x is 3 or less. But when x is 4, this gives me the https://msdn.microsoft.com/en-us/library/hzsytfc8.aspx error: run-time error 6 Overflow I don't understand why this is. I can set intID to 40000 directly without any problems, so it's obviously capable of storing large numbers. vb6 integer overflow share|improve this question edited May 5 '11 at 11:15 asked May 5 '11 at 9:58 Urbycoz 2,109124281 add a comment| 3 Answers 3 active oldest votes up vote 28 down vote accepted You *cannot set a vb6 integer to 40000 as they are signed 16 bit numbers so +32767 is the maximum. Long is the 32 http://stackoverflow.com/questions/5895816/vb6-overflow-error-with-large-integers bit type. However as a caveat, if you were to: Dim lngID As Long lngID = 4 * 10000 You would still get an overflow as literal numbers default to Integer, to correct that just type one as long with & or cast one as long using CLng(): Dim lngID As Long lngID = 4 * 10000& lngID = 4 * CLng(10000) Update: share|improve this answer edited May 5 '11 at 11:41 onedaywhen 34k85699 answered May 5 '11 at 10:05 Alex K. 107k16149195 But why don't I get an error with this: intID= 40000 –Urbycoz May 5 '11 at 10:10 2 In vb6, Dim intID as integer: intID = 40000 will error 100% of the time –Alex K. May 5 '11 at 10:14 1 Because 3 * 10000 fits in an integer (its < 32767), 4 * 10000 does not –Alex K. May 5 '11 at 10:21 @Urbycoz the great majority of your questions have been about VB.NET . For the avoidance of any doubt, could you confirm that you are definitely seeing this behaviour in VB6 ? –AakashM May 5 '11 at 10:48 1 @Alex- You're right. It's behaving as you say for me now. Not sure what changed. Thanks for your help! –Urbycoz May 5 '11 at 11:21 | show 1 more comment up vote 8 down vote in VB6, the Integer type is a whole number which ranges from -32768 to 32767. You would be best using the Long type here. share|improve this answer answered May 5 '11 at 10:06 trickwallett 2,00871
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings http://stackoverflow.com/questions/909103/clong-overflow-in-vb6 and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; overflow error it only takes a minute: Sign up Clong overflow in VB6 up vote 1 down vote favorite I'm having an overflow error in VB 6.0 when using the Clong datatype because of really big values. How to overcome this? Is there anything else available higher than the Clong datatype? vb6 types share|improve this question edited May 26 '09 at 10:25 overflow error in Svante 31.9k548102 asked May 26 '09 at 5:57 stack_pointer is EXTINCT 63662948 add a comment| 5 Answers 5 active oldest votes up vote 5 down vote Depending on how big your really big values are, the VB6 Currency data type might be a good choice. It supports values in the range -922,337,203,685,477.5808 to 922,337,203,685,477.5807. share|improve this answer answered May 26 '09 at 6:33 Joe 82.7k21118233 add a comment| up vote 3 down vote You could use a Double instead of a Long since it can hold larger numbers. The function is CDbl() instead CLng(). In VB6.0, a Long is 32-bits and can hold values up to: 2,147,483,648 A Double is 64-bits and can old values up to: 1.79769313486231570E+308 EDIT: Please refer to this reference share|improve this answer edited May 26 '09 at 9:26 answered May 26 '09 at 6:03 Jose Basilio 36.8k792111 Be careful! A double doesn't actually hold more precision, though it can hold larger numbers. Doubles on most systems are rounded to somewhere around 15 digts. For example, 123456789012345678901234567890 will become 1.2345678901234568e29. –Curt Samp