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

x
Solved

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

Posted on 2009-12-20
Medium Priority
424 Views
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
0
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

http://support.microsoft.com/kb/189862

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

~bp

0

Author Closing Comment

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

Author Comment

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

## Featured Post

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