Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Date type format

Status
Not open for further replies.

SteveJR

Programmer
Aug 13, 2001
72
0
0
GB
Help!

Has anyone experienced the following and if so how did you solve it!

I have declare a UDT with various field types with 3 being date fields. I am then using the CopyMemory function to move a string into the UDT. However, I am finding that all the fields after the 3 date fields are two bytes out!

The first date field will always contain a value but the next two might not. I am guessing that the string is being shifted into date fields 2 & 3 which is causing the problem.

Does anyone know of a solution to this?

Any help would be much appreciated.

Thanks,

Steve
 
Try doing the copymemory to a temporary string first and then moving it into the UDT.
 
I'm not too sure if this would work. Are you saying to do the CopyMemory statement from Str1 to Str2 and then do another CopyMemory statement from Str2 to UDT?

Thanks,

Steve
 

I'm not sure if this is relevant to your problem but I believe VB stores data with 4 byte alignment. If you have an integer data type in your UDT then it uses 4 bytes of memory, 2 to store the value and 2 empty bytes.

Type MyUDT
dtMyDate1 as Date '8 bytes
iMyInteger as integer '2 bytes plus 2 empty bytes
dtMyDate2 as Date '8 bytes
End Type

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top