Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA Long data type overflow

Hi !

The following code generates Overflow error:

Dim NumberP As Long
NumberP = 1078282205 * 31

According to MSDN:
Long variables are stored as signed 64-bit (8-byte) integers ranging
in value from -9,223,372,036,854,775,808 through
9,223,372,036,854,775,807.

What is going wrong there ?
Maybe VBA Long data size differs from VB Long data size ?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBA Long data type overflow

VBA long is 4byte(32bit) signed.

If you need larger numbers try Currency which is 8byte scaled integer
see VBA help DataType summary.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(Jean Stax) wrote:

Dim NumberP As Long
NumberP = 1078282205 * 31


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default VBA Long data type overflow

Different applications/compilers/environments do define data types
differently. For Excel (from XL/VBA Help):

Long Data Type

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers
ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration
character for Long is the ampersand (&).



In article ,
(Jean Stax) wrote:

Hi !

The following code generates Overflow error:

Dim NumberP As Long
NumberP = 1078282205 * 31

According to MSDN:
Long variables are stored as signed 64-bit (8-byte) integers ranging
in value from -9,223,372,036,854,775,808 through
9,223,372,036,854,775,807.

What is going wrong there ?
Maybe VBA Long data size differs from VB Long data size ?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default VBA Long data type overflow

Jean,

Longs are 4-bytes (32-bits) ranging in value from -2,147,483,648 to
2,147,483,647 . Where did you find that definition in MSDN?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jean Stax" wrote in message
om...
Hi !

The following code generates Overflow error:

Dim NumberP As Long
NumberP = 1078282205 * 31

According to MSDN:
Long variables are stored as signed 64-bit (8-byte) integers ranging
in value from -9,223,372,036,854,775,808 through
9,223,372,036,854,775,807.

What is going wrong there ?
Maybe VBA Long data size differs from VB Long data size ?

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Long data type overflow

http://msdn.microsoft.com/library/de...us/vblr7/html/
vadatlong.asp

Which includes a caution about VB6 Longs.
--
Regards,
Tom Ogilvy


Chip Pearson wrote in message
...
Jean,

Longs are 4-bytes (32-bits) ranging in value from -2,147,483,648 to
2,147,483,647 . Where did you find that definition in MSDN?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jean Stax" wrote in message
om...
Hi !

The following code generates Overflow error:

Dim NumberP As Long
NumberP = 1078282205 * 31

According to MSDN:
Long variables are stored as signed 64-bit (8-byte) integers ranging
in value from -9,223,372,036,854,775,808 through
9,223,372,036,854,775,807.

What is going wrong there ?
Maybe VBA Long data size differs from VB Long data size ?

Thanks





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://CannotDeleteFile.net - Cannot Delete File? Try Long Path ToolFilename is too long? Computer Complaining Your Filename Is Too Long? TheLong Path Tool Can Help While most people can go about their businessblissfully unaware of the Windo Max Loger Excel Discussion (Misc queries) 0 June 14th 11 04:30 PM
when I type a long number it shows up as smaller number and + SandyC Excel Discussion (Misc queries) 5 March 17th 10 07:47 PM
how do I type long paragraph into a cell? Sunshine Excel Discussion (Misc queries) 3 October 13th 07 01:26 AM
Data overflow to second worksheet jv Excel Worksheet Functions 0 March 30th 06 06:06 PM
VBA overflow Tom Ogilvy Excel Programming 3 September 2nd 03 09:04 PM


All times are GMT +1. The time now is 04:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"