|
-
Jul 1st, 2008, 08:30 AM
#1
Thread Starter
New Member
Searching for strings within a record
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:
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
Knowing me its probably just some silly little typing error, but any help with this problem would be greatly appreciated.
-
Jul 2nd, 2008, 02:59 AM
#2
Thread Starter
New Member
Re: Searching for strings within a record
Anyone know what i'm doing wrong here?
-
Jul 2nd, 2008, 04:58 AM
#3
Re: Searching for strings within a record
You are doing a binary compare... check the value in file and textbox, are they the same case? Try using StrComp().
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|