473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 835

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

Similar topics

4
by: Frak | last post by:
Hi. I have a text file which in which the lines are numbered this way: - - and so....
17
by: AL | last post by:
Hi I have a bunch of text files which need to be organized. What I want to do is to select three continuous lines from each text file and write them down in another text file. Each of those three...
2
by: manontheedge | last post by:
Private Sub readFile() Open "example.txt" For Input As #1 Dim sInputData As String While Not EOF(1) Line Input #1, sInputData
21
by: Umesh | last post by:
/*program to search a* in a text file & write output in a file.* indicated any character*/ #include<stdio.h> #include<stdlib.h> int main(void) { FILE *f,*fp; f=fopen("c:/1.txt","r");...
4
by: ume$h | last post by:
/*program to search a* in a text file & write output in a file.* indicated any character. IT IS WORKING BUT HOW TO GENERALISE IT FOR A LONG STRING LIKE umesh*** OR Suppose I want to find all words...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.