use vbscript combine several numbers bitwise to get a 64 bit number

Posted on 2009-12-20
Last Modified: 2012-06-27
I have this code that is used to produce a 64 bit number to uniquely identify an item. The problem is that I now need to do the same thing in a classic asp page. Can it be done? If so, how?

            '   Store Years 1900 To 2155 In Eight Bits
            Dim iYear As Long = CLng((breakout.parsedDate.Year - 1900) And &HFF)

            '   Store Months In 4 Bits (1-12 Fits In 0 - 15)
            Dim iMonth As Long = CLng(breakout.parsedDate.Month And &HF)

            '   Store Days In 5 Bits (0-31)
            Dim iDay As Long = CLng(breakout.parsedDate.Day And &H1F)

            '   Store Numbers 0 To 131071 Taking Up 17 Bits
            Dim iStore As Long = CLng( And &H1FFFF)

            '   Register Numbers 0 To 999 Taking Up Ten Bits
            Dim iRegister As Long = CLng(breakout.register And &H3FF)

            '   Ticket Numbers 0 To 131071 Taking Up 17 Bits
            Dim iTicket As Long = CLng(breakout.ticket And &H1FFFF)

            '   Shift Items To Their Proper Offset
            iStore = iStore << 17
            iRegister = iRegister << 34
            iYear = iYear << 44
            iMonth = iMonth << 52
            iDay = iDay << 56

            '   "And Them Together"
            Dim iHash As Long = iTicket Or iStore Or iRegister Or iYear Or iMonth Or iDay
            Return iHash.ToString
Question by:dgerler
    LVL 51

    Accepted Solution

    I don't think this is going to be possible in vbscript.  The largest obstacle is the fact that vbscript doesn't support a 64 bit integer, only 32 bit max.  In addition there are no bit shift operators, but I think that could be worked around with multiplication by powers of 2.

    In VBA there are some ways to work around this with the Currency data type, but I haven't seen an adaptation of this to vbscript, and the vbscript currency data type seems to be less than 64 bits

    I'm sorry to say I think you are out of luck.



    Author Closing Comment

    Thanks anyway. I guess I'll just have to do it in a dll and return a string.

    Author Comment

    I'll make the number in a dll and return a string to the asp. Thanks anyway.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now