[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2009-12-20
Medium Priority
Last Modified: 2012-06-27
I have this vb.net 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(breakout.store 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
  • 2
LVL 59

Accepted Solution

Bill Prew earned 2000 total points
ID: 26091413
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

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

Author Comment

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

872 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