Results 1 to 7 of 7

Thread: Strange case of Overflow error

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Strange case of Overflow error

    I am converting R, G, B colors to a Long variable.

    I believe that this is the correct way to do it:

    Dim lngColor As Long

    lngColor = B * 65536 + G * 256 + R

    R, G, and B have been defined as Bytes and their value are R=189, G=197, B=197


    I get an overflow error on

    G * 256

    but I do not get an error on B * 65536

    For example:

    Dim C1 As Long
    Dim C2 As Long
    Dim C3 As Long


    C3 = B * 65536 <---------- No error
    C2 = G * 256 <---------- Overflow
    C1 = R
    Last edited by jmsrickland; Aug 28th, 2012 at 02:57 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

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