+ Reply to Thread
Results 1 to 2 of 2

Declaring INTEGER vrs. LONG

  1. #1
    Forum Contributor
    Join Date
    03-03-2005
    Posts
    315

    Declaring INTEGER vrs. LONG

    I am given to understand, on good authority, that in VBA the "default character" of a number is LONG. This is to say, EXCEL loves to treat numbers primarily as LONG unless coerced to handle them by an explicit declaration (of INTEGER or DOUBLE). For this reason, and circumstances permitting, declaring any number as LONG causes EXCEL to use memory more efficiently. Which seems to fly in the face of the fact that INTEGER attracts less memory space (2 bytes) than Long (4 bytes). Anyhow, the cut is that if DOUBLE is not required, we would be better off ALWAYS declaring LONG even when INTEGER range is intended.

    Can anyone comment on the above before I set the principle in concrete?


    davidm

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by davidm
    I am given to understand, on good authority, that in VBA the "default character" of a number is LONG. This is to say, EXCEL loves to treat numbers primarily as LONG unless coerced to handle them by an explicit declaration (of INTEGER or DOUBLE). For this reason, and circumstances permitting, declaring any number as LONG causes EXCEL to use memory more efficiently. Which seems to fly in the face of the fact that INTEGER attracts less memory space (2 bytes) than Long (4 bytes). Anyhow, the cut is that if DOUBLE is not required, we would be better off ALWAYS declaring LONG even when INTEGER range is intended.

    Can anyone comment on the above before I set the principle in concrete?


    davidm
    Hi,

    Integer handles up to 32768, ie 8 bits counting, useful (up to Excel 2003) for columns, not useful for Rows.

    Long is required for Rows.

    Does this help?

    ---

    also noted that Excel 2007 will require 'long' to handle columns.

    ---
    Last edited by Bryan Hessey; 12-07-2006 at 01:52 AM.
    Si fractum non sit, noli id reficere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1