|
-
Oct 15th, 2010, 12:25 PM
#1
Thread Starter
New Member
Bytes To Date
Hello
I needed to save a date to a smart card, so first I had to serialize my 8 byte Date variable to a byte array. I did this with kernel32 copymemory.
Actually I'm saving just the four last bytes because I dont need the time part.
My problem is that I cant retrieve the date from the bytes. I tried the following code which results to overflow:
m_expirationDate = CDate((m_rawBytes(0) * 16777216) + (m_rawBytes(1) * 65536) + (m_rawBytes(2) * 256) + m_rawBytes(3))
So how can this be done?
-
Oct 15th, 2010, 03:52 PM
#2
Re: Bytes To Date
Welcome to the forums.
Try changing 256 to 256& and see if 1) error goes away and 2) you get what you expect; probably not.
I suspect that m_rawbytes(2) * 256 is the overflow, 256 is treated as Integer unless ampersand suffix provided.
-
Oct 16th, 2010, 03:47 AM
#3
Thread Starter
New Member
Re: Bytes To Date
The answer was below my eyes:
Date to bytes:
CopyMemory dateBytes(0), m_expirationDate, 8
bytes to Date:
CopyMemory m_expirationDate, dateBytes(0), 8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|