i have this code where when i click a button it increases a value in my listbox by 1 however every time i try to increase that value i have to click on it to select again. How can i just click on it once to select and click the button to increase the value as much as i want. Here is my code and any help is appreciated.
Code:
Dim sriv As IO.StreamReader = IO.File.OpenText("C:\Users\Mike\Desktop\Production AP\PRODUCTION_DATA_APP\PRODUCTION_DATA_APP\My Project\data.txt")
'must creat a temp file becaue program scans from top to bottom and never goes back
Dim swdel As IO.StreamWriter = IO.File.CreateText("Tempinv.txt")
Dim failed As Integer
Dim time, quantity, passed, comment As String
Dim Utime As String = 0
ListBox1.SelectionMode = SelectionMode.MultiExtended
'do untill item found and then delete
Do Until sriv.EndOfStream
time = CStr(sriv.ReadLine)
quantity = CStr(sriv.ReadLine)
passed = CStr(sriv.ReadLine)
failed = CDbl(sriv.ReadLine)
comment = CStr(sriv.ReadLine)
If Trim(Mid(ListBox1.SelectedItem, 1, 13)) = time Then
If failed >= 0 Then
swdel.WriteLine(time)
swdel.WriteLine(quantity + 1)
swdel.WriteLine(passed)
swdel.WriteLine(failed)
swdel.WriteLine(comment)
End If
Else
swdel.WriteLine(time)
swdel.WriteLine(quantity)
swdel.WriteLine(passed)
swdel.WriteLine(failed)
swdel.WriteLine(comment)
End If
'Next i
Loop
'must close both temp and our file
swdel.Close()
sriv.Close()
'delete old file and put new one instead
IO.File.Delete("C:\Users\Mike\Desktop\Production AP\PRODUCTION_DATA_APP\PRODUCTION_DATA_APP\My Project\data.txt")
IO.File.Move("tempinv.txt", "C:\Users\Mike\Desktop\Production AP\PRODUCTION_DATA_APP\PRODUCTION_DATA_APP\My Project\data.txt")
'outputs the time being deleted
Button6_Click(sender, New System.EventArgs())