Ok so i'm trying to validate numeric input through the use of input boxes. I'm trying to use a try catch statement to catch anything thats non numeric and it works fine. But the only problem i'm having is looping through the array. For example an input box pops up asking John for hours worked, enters 20 and clicks ok. Then loops to the next inputbox asking Jake for hours worked, enters 30 clicks ok. Now when the next question comes up for 'Jeff' If he clicks 'ok' 'cancel' or enters a non integer it catches it, displays 'Please enter a numeric value' then goes to the next person. Once it catches an error I need the loop to reask that same question to the same person before proceeding to the next. Anyone give me any tips? Theres a lot more code to it, but i just included the arrays and the subprocedure to get the hours worked.
Code:
Dim names() As String = {"John", "Jake", "Jeff", "Juan", "Leo", _
"Sally", "Tom", "James", "Brandon", "Julius"}
Dim amount(9) As Integer
Sub getEachName()
Dim intCount As Integer 'loop counter
'Add header to list box
lstTotals.Items.Add("Name and Hours Worked")
'Get the total hours and put them in a list box with name
For intCount = 0 To 9
Try
amount(intCount) = CInt(InputBox("Enter amount of hours" _
& vbLf & names(intCount)))
lstTotals.Items.Add(names(intCount) & " " & amount(intCount))
Catch Exception As SystemException
MessageBox.Show("Please enter a numeric value.")
------> ????????????????
End Try
Next intCount
End Sub
Comment