Hi there, im fairly new to programming, let alone visual basic itself, and ive run into a spot of trouble with one of my programs.
I'm trying to make a car filing systems of sorts where a user can enter details of cars to be stored to a file as records. These records can then be searched by make and model for matching records which will then be displayed in a list box. Problem is that it doesn't seem to be working correctly.
Here is the relevant section of code:
Knowing me its probably just some silly little typing error, but any help with this problem would be greatly appreciated.Code:Option Explicit Private Type CarDetails RegNumber As String * 8 make As String * 15 model As String * 10 YearofManufacture As Integer price As Currency End Type Dim NumberOfRecords As Integer Dim Filename As String Private Sub cmdSearchMakeModel_Click() Dim counter As Integer Dim car As CarDetails Dim years As String Dim price As String Dim make As String Dim model As String lstSearchResults.Clear Filename = txtFilename.Text 'get file pathway Open Filename For Random As #1 Len = Len(car) NumberOfRecords = LOF(1) / Len(car) ' find number of records in file For counter = 1 To NumberOfRecords 'loop for all records Get #1, counter, car model = car.model make = car.make If model = txtSearchModel.Text And make = txtSearchMake.Text Then 'search each model to see if the search criteria matches up, and if it does.. years = car.YearofManufacture price = Format(car.price, "Currency") datatodisplay = car.RegNumber & " " & car.make & " " & car.model & " " & years & " " & prices lstSearchResults.AddItem datatodisplay 'add the record's details to the list End If Next counter Close #1




Reply With Quote