Finding a phrase in a text file?
I have a text file like this;
Bananas=60
Tomatoes=34
Rasberries=102
Apples=23
If I have a form with textboxes or numericalupdowns is there anyway I could change the number of fruit and veg in the text file?
Could it be possible to somehow open the textfile into the form then, edit & save?
Thanks
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
What have you done so far? Please post your code here and someone will help you. Do wrap your programming code blocks within [code]..[/code] tags.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
I have no code at the moment.
All i have is abunch of textboxes for the numbers of fruits.
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
Ive got small problem.
It wont open the values from the text file when I have it like this
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'ToDo: Perform Error Checking
Dim fStream As New System.IO.FileStream("c:\Users\Ollie\Desktop\test.txt", IO.FileMode.Open)
Dim sReader As New System.IO.StreamReader(fStream)
Dim line() As String
Do While sReader.Peek > -1
line = sReader.ReadLine.Split(New Char() {"="c}, StringSplitOptions.RemoveEmptyEntries)
If line.Count <> 2 Then Continue Do 'wrong format
If Not IsNumeric(line(1)) Then Continue Do 'wrong format
Select Case line(0).ToLower
Case "A"
A.Text = line(1)
Case "B"
B.Text = line(1)
Case "C"
C.Text = line(1)
Case Else
'Bad Fruit
End Select
Loop
fStream.Close()
sReader.Dispose()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'ToDo: Perform Error Checking Andalso Validate TextBoxes
Dim fStream As New System.IO.FileStream("c:\Users\Ollie\Desktop\test.txt", IO.FileMode.OpenOrCreate)
Dim sWriter As New System.IO.StreamWriter(fStream)
sWriter.WriteLine("A" & " " & A.Text)
sWriter.WriteLine("B" & " " & B.Text)
sWriter.WriteLine("C" & " " & C.Text)
sWriter.Close()
fStream.Close()
sWriter.Dispose()
End Sub
End Class
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0
BleepyE
Junior Poster in Training
87 posts since Dec 2010
Reputation Points: 10
Solved Threads: 0