By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,044 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,044 IT Pros & Developers. It's quick & easy.

Searching for a value in a text file

P: 1
I am trying to search for a number >= to some vale in a text file. The code is failing to work.

Sub SearchFileNumber()
Dim CarRegistration As String = ""
Dim DateSold As String = ""
Dim NumberOfRepairs As String = ""
Dim Found As Boolean = False
Dim SearchString As String
Dim FileHandle As IO.StreamReader
FileHandle = New IO.StreamReader("CARSALES.TXT")
Console.WriteLine("Enter Number of Repairs")
SearchString = Console.ReadLine
While Not FileHandle.EndOfStream
Dim line As String = FileHandle.ReadLine()

If Val(NumberOfRepairs) >= Val(SearchString) Then
Console.WriteLine(line)
Found = True
End If

End While
If Found = False Then
Console.WriteLine("No cars found")
End If
Console.ReadKey()
FileHandle.Close()
Main()
End Sub

The above is the code i came up with. Please help
Aug 31 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.