468,119 Members | 1,972 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

Searching for a value in a text file

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
0 708

Post your reply

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

Similar topics

4 posts views Thread by Frak | last post: by
17 posts views Thread by AL | last post: by
21 posts views Thread by Umesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.