Domino
Joined: 17 Nov 2006 Posts: 2
|
Posted: Sat Nov 18, 2006 12:03 am Post subject: User-defined data types containing non-strings |
|
|
Hi - I'm stuck with something basic. I am using a user-defined data type to define a record (e.g. Customer name, Customer ID). When I put both fields of the record as strings I get no problem writing the record to a direct access file. But when I put the ID as an integer, the file becomes unreadable and data can't be retrieved again.
e.g.
Private Type CustomerType
CustomerID As Integer
CustomerName As String * 10
End Type
Dim Customer As CustomerType
Open App.Path & "\Customers.dat" for Random As #1 Len = Len(Customer)
NumberOfRecords = LOF(1) / Len(Customer)
Put #1, NumberOfRecords + 1, Customer
Close #1
I was advised to convert the text box that contained the customer ID to an integer before assigning a variable to it.....
Customer.CustomerID = CInt(txtCustomerID.Text)
but it didn't help. MsgBox (VarType(Customer.CustomerID)) showed 2, which is an integer. So what is the problem? Why does it write the ID to my direct access file as a square box? Any ideas appreciated, thanks. |
|