Run time error 6 Overflow

  • 15 years ago

    Hi all,

    why following code end by "Run time error 6 Overflow"?

    .....

    Dim byI As Byte
    For byI = 5 To 1 Step -1
    Next byI

    .....

  • 15 years ago

    As you have declared byI to be a Byte, this means that the Step -1 is typed as Byte. -1 can not be represented by the Byte data type, so the overflow occurs. You probably need to use an Integer.

    See this from MSDN



  • 15 years ago

    Just out of Intrest can you use a two's complement system in visual basic to represent negative numbers? e.g. the most significant bit is negative.

  • 15 years ago

    No. There is no concept of unsigned in the intrinsic VB6 types, so you are limited by what VB has to offer. For example, VB6 provides a Long, but there is no equivalent Unsigned Long, such as you might be able to do in C, where the underlying storage is the same size (e.g. 4 bytes) but the MSB is treated differently.

    Again, I refer you to MSDN using this link describing the available data types.

    The only unsigned type is the Byte.

  • 15 years ago

    lol ok I know the datatypes I've never had much reason to work with the byte datatype as of yet was just curious don't byte my head off, yes cheap joke I know lol

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray