+ Reply to Thread
Results 1 to 5 of 5

Can you declare only a lower bound for an array and let the upper bound float?

  1. #1
    Registered User
    Join Date
    10-01-2008
    Location
    Park City
    Posts
    59

    Can you declare only a lower bound for an array and let the upper bound float?

    Can you declare only a lower bound for an array without using the Option Base 1 command?
    I'm worried I'll get all screwed up in the arithmetic when my arrays start at 0.
    I want to have the lower bound declared at 1 and have the upper bound float depending on the data I'm trying to load into the array.

    Thanks

    GG

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can you declare only a lower bound for an array and let the upper bound float?

    Hi GG,

    Try something like this:
    Please Login or Register  to view this content.
    Lewis

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Can you declare only a lower bound for an array and let the upper bound float?

    Wouldn't it be simpler to use Option Base 1?

    I know when I've needed to work with 1-based arrays, eg arrays populated from a range, it's helped me avoid errors.
    If posting code please use code tags, see here.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Can you declare only a lower bound for an array and let the upper bound float?

    Quote Originally Posted by Norie View Post
    Wouldn't it be simpler to use Option Base 1?
    1. Simpler yes, but possibly a recipe for disaster.

    a. What happens if 'Option Base 0/1' is accidentally removed from (or never inserted at) the top of the module?

    b. When declaring an array with an 'Explicit Lower Bound' (dim x(1 to 6) as Double) , it is difficult to misinterpret what the 'lower bound' is supposed to be. This is especially true when looking at code written by someone else.

    Lewis

  5. #5
    Registered User
    Join Date
    10-01-2008
    Location
    Park City
    Posts
    59

    Re: Can you declare only a lower bound for an array and let the upper bound float?

    Quote Originally Posted by LJMetzger View Post
    1. Simpler yes, but possibly a recipe for disaster.

    a. What happens if 'Option Base 0/1' is accidentally removed from (or never inserted at) the top of the module?

    b. When declaring an array with an 'Explicit Lower Bound' (dim x(1 to 6) as Double) , it is difficult to misinterpret what the 'lower bound' is supposed to be. This is especially true when looking at code written by someone else.

    Lewis
    Lewis,

    Thank you. This was my concern.
    I just posted another thread regarding arrays (I've not included the lower bound code yet but I will).
    Is it possible for you to have a quick look at it to see where my syntax is wrong. It's basic stuff I'm trying to understand here.

    Thanks

    GG

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Percentile Array with an upper and lower bound
    By KiaCzar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-23-2013, 12:14 PM
  2. Bound Combo box in userform
    By Jennifer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2006, 04:10 AM
  3. Forms, Bound Columns etc
    By Michael Beckinsale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2006, 06:55 AM
  4. Data Bound Controls in VBA??
    By Trip in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2005, 12:52 PM
  5. Replies: 6
    Last Post: 07-05-2005, 03:05 PM

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