Help Needed with VB6 Data Type to VB05 Data Type Conversions
Hello,
I'd like some advice on solving a problem having to do with data type size changes when moving from VB6 to VB05. Specifically how do I convert the VB6 data type to the VB05 data type?
A simple one is VB6 "Integer" (2-bytes) is a "Short" in VB05.
With VB6 the "Date" (8-bytes) appears to be (7-bytes) in VB05 (My data on its size seems to vary).
With VB6 the "Currency" (8-bytes) is replaced with "Decimal" (16-bytes).
My current project requires me to read a binary file made up of an array of different VB6 data types using a VB05 based program.
I created a new Structure with VB05 data types and read the binary file. My data appears corrupted due to the differences in size, specifically "Data" and "Currency".
I'd love some suggestions on how to read the VB6 binary file while getting the data type sizes adjusted or corrected.
Thanks Pauly
[981 byte] By [
Paulyz] at [2007-12-24]
Hey guys thanks for the replies.
I did some research on what you sent and other searches. I'm slightly better than where I was. I found a suggestion on using Int64 in place of Currency/Decimal and it seems to read it correctly. Conversion is by the following example:
Dim PriceFix As Decimal = Decimal.FromOACurrency(ODFL.Price)
I'm still stumped by an Array of Strings and the Date. I've included below some test code to test the conversion of my User Defined Type into a Structure, dimensioning and mainly the read of the VB6 file (OldDiskFileLayout). Note that the File that is being read is binary and generated from a VB6 program that I cannot change. Hence it has the data type sizes of VB6.
I run the program and set a BP before the Close statement. I usually get a "Bad Record Length" error before reaching the BP. I believe that the ODFL Structure length is off. I should have a Len(ODFL)= 20 but it comes back with a value of 14...
In VB6 Len(ODFL)=20. It seems like its picking up a 4-byte lenght for the String versus 10.
To boot I'm not even sure that String is appropriate considering its a 2-byte value in VB05 versus 1-byte in VB6. I'm running with it until I can find how to read the old String data as single bytes and convert it into a string.
Is it appropriate to find the lenght of a Structure using ?Len(StructureName)?
Why isn't the Structure Length showing an increased size after executing "Activity" as New String (" ", 10) ?
Please keep the suggestions coming. Thanks PaulyZ
Option
Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
Private Structure OldDiskFileLayout
Public Account As Short '2-bytes
Public Activity As String '10-bytesPublic Date As Date '8-bytesEnd StructureDim Count As Single 'Number of file entries in OldDiskFilePrivate Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.ClickGetData()
End SubPrivate Sub GetData()Dim ODFL As OldDiskFileLayout 'Old Disk File Layout InformationODFL.Activity = New String (" ", 10) FileOpen(1, "C:\OldDiskFile", OpenMode.Random, , , )FileGet(1, ODFL)
'Read a entryFileClose(1)
End Sub
End Class