It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

User-defined data types containing non-strings

Moderator: dafunkymunky

User-defined data types containing non-strings

Postby Domino on Fri Nov 17, 2006 11:03 pm

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.
Domino
 
Posts: 2
Joined: Fri Nov 17, 2006 10:33 pm

Who is online

Users browsing this forum: No registered users and 6 guests