Bigbadborris
Active member
- Joined
- Aug 21, 2013
- Messages
- 35
- Programming Experience
- Beginner
Hi all
I have a txtfile that contains customer info. each line in the file is a different customer. The line length is 581 characters long. Each line contains a date for when the product was last serviced the date starts at character 474 and is 8 characters long with the following format ##/##/## I have a textbox where the user can enter a date in the same format.
I am trying to create a program that searches through the text file for any customer record in which the service date is equal to or before the date in the textbox (i.e Service is due/overdue.) It should then record the customer name in another text file for processing later.
This is what I have so Far but is dosnt seem to work
I get this error "startIndex cannot be larger than length of string. Parameter name: startIndex" for the line ServiceDate = line.substring(474,8)
Can anyone shed some light on this
Many Thanks
I have a txtfile that contains customer info. each line in the file is a different customer. The line length is 581 characters long. Each line contains a date for when the product was last serviced the date starts at character 474 and is 8 characters long with the following format ##/##/## I have a textbox where the user can enter a date in the same format.
I am trying to create a program that searches through the text file for any customer record in which the service date is equal to or before the date in the textbox (i.e Service is due/overdue.) It should then record the customer name in another text file for processing later.
This is what I have so Far but is dosnt seem to work
VB.NET:
Dim File_NameIN As String = "C:\DRITXT\CUSTKEYA.txt" ' Adds Source file location to a String Variable
Dim File_NameOUT As String = "C:\DRITXT\LETTER.txt" ' Adds Destination file location to a String Variable
Dim objWriter As New System.IO.StreamWriter(File_NameOUT)
Dim DateRange As String = txtDateRange.Text
Dim ServiceDate As String
For Each line As String In File.ReadAllLines(File_NameIN)
ServiceDate = line.Substring(474, 8)
If ServiceDate = DateRange Then
Name = line.Substring(0, 30).ToLower
objWriter.WriteLine(Name)
End If
Next line
objWriter.Close()
I get this error "startIndex cannot be larger than length of string. Parameter name: startIndex" for the line ServiceDate = line.substring(474,8)
Can anyone shed some light on this
Many Thanks