Question using LSET
Posted on 2006-10-24
I want to read the contents of a file into a UDT that is basically a "buffer" and then use LSET to move it into a UDT that has all the fields layed out properly. The UDT I am reading the line into has just a single variable defined as a fixed-length string the length of the data record...
Public Type KPAyData
Buffer As String * 4340
Public PayrollBuffer as KPayData
The data is payroll information. As such, it has a number of repeating fields for earnings, taxes, deductions, etc. I have defined a UDT for each of these repeating groups of fields, and used an array of that type in the appropriate place in the UDT that defines all the data. A small example is as follows...
Public Type PayrollTaxDeduction
TaxClass As String * 1
TaxState As String * 6
TaxLocality As String * 10
TaxAmount As String * 12
Public Type KPayType
EmployeeID As String * 11
EmployeeSSN As String * 9
TaxDeductions(1 to 10) As PayrollTaxDeduction
Public PayrollRecord as KPayType
If I do a Len() and LenB() on the types, the lengths come out correctly, but when I try to LSet PayrollRecord = PayrollBuffer, I get a Type Mismatch error. I am suspecting that using the array of UDTs in KPayType may be causing the error, but not certain. Can someone either confirm that or give me another avenue to pursue in determining why I am getting the error.
Also, if you can provide an alternative way to do this, I would appreciate it. There are 75 repeating groups just for deductions and each group contains five fields. I would hate to have to hard-code all of those (641 fields altogether).