Results 1 to 4 of 4

Thread: xlBorderWeight constants

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    xlBorderWeight constants

    Anyone have any idea why xlMedium is -4138?

    xlHairline = 1
    xlThin = 2
    xlMedium = -4138
    xlThick = 3

    The programmer must have been drunk the day he wrote those constants.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: xlBorderWeight constants

    The same name (xlMedium) was probably used for another set of constants before it was used for xlBorderWeight - and as each name can only have one value, the value had to stay what it was previously.

    It doesn't actually matter much tho, as you should just use the constants anyway.. but it does mean that if you really want to work with the values instead then your code becomes more complex.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    Re: xlBorderWeight constants

    I was doing some automation that draws some "graphics" by coloring in cells and setting their borders. I have an ini file with the border width. I decided to write a function to convert from my values (1 through 4) to the Excel border weight constants, just in case they decide Excel is too slow at drawing and I rewrite that portion to use GDI.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: xlBorderWeight constants

    I see.. well calling functions is slow, so (as your values are in a small range) I'd recommend using an array instead, eg:
    Code:
    Dim BorderWidthToBorderWeight(1 to 4) as Long
      BorderWidthToBorderWeight(1) = xlHairline
      BorderWidthToBorderWeight(2) = xlThin
      BorderWidthToBorderWeight(3) = xlMedium
      BorderWidthToBorderWeight(4) = xlThick
    Then in your code, this array would be used in the same way as the function would be.

Posting Permissions

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



Click Here to Expand Forum to Full Width