Results 1 to 6 of 6

Thread: [RESOLVED] Can't borrow Long DataType from VB.Net directly into VB6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2010
    Far East

    Resolved [RESOLVED] Can't borrow Long DataType from VB.Net directly into VB6

    Hi guys

    I just realized Long in V6 is much smaller than VB.Net ie -2,147,483,648 to 2,147,483,647 vs -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807. This has created a VB6 code copied from VB.Net to calculate a number to become zero due to overflow. Once i switch to Double in VB6 it is ok. Did i now get it right?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013

    Re: Can't borrow Long DataType from VB.Net directly into VB6

    You could also use the Currency datatype
    Currency variables are stored as 64-bit (8-byte) numbers in an integer format, scaled by 10,000 to give a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right.
    This representation provides a range of -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
    The type-declaration character for Currency is the at sign (@).

    The Currencydata type is useful for calculations involving money and for fixed-point calculations in which accuracy is particularly important.

  3. #3
    Fanatic Member
    Join Date
    Jun 2015

    Re: Can't borrow Long DataType from VB.Net directly into VB6

    Pass max and min values from .net to vb
    And see how the vb data types handle them it will literally tell you if there is still a problem. If you don’t need to do math on them just pass them as a string or do all your math on the .net side working with strings of digits coming from vb

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011

    Re: [RESOLVED] Can't borrow Long DataType from VB.Net directly into VB6

    VB6 lacks a 64 bit integer type. However, a Double is 64 bits. If all you care about is range, then a Double may and I stress may suffice as a substitute. I'm not sure about the how much difference there is in the range differences between a 64 bit integer and a Double, I've never examined it. But if you also care about the bitwise representation then you're going to find yourself in problems. If the bitwise representation is important, then a better option is to be clever by using combining two 32 bit integers.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Near Nashville TN

    Re: [RESOLVED] Can't borrow Long DataType from VB.Net directly into VB6

    It's not so much about "range" as it is about "accuracy" (significant digits). A LongLong has far more "accuracy" than a Double, but it has far less "range". That's the tradeoff (with both being 8 bytes).

    If you're careful about it, you actually can get a LongLong (via a Variant) into VB6. But typically, a Currency works quite nicely for these purposes, as it's actually a LongLong with a forced decimal at the fourth place.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Join Date
    Feb 2006

    Re: [RESOLVED] Can't borrow Long DataType from VB.Net directly into VB6

    Depending on what you are really doing that is putting your calculations over the edge you might also find this useful:

    MulDiv function

    Note that it has a weird bug though:

    What is the historical reason for MulDiv(1, -0x80000000, -0x80000000) returning 2?

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