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

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
Who is Participating?
Bill PrewCommented:
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.


dgerlerAuthor Commented:
Thanks anyway. I guess I'll just have to do it in a dll and return a string.
dgerlerAuthor Commented:
I'll make the number in a dll and return a string to the asp. Thanks anyway.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.