D
Dennis D.
Hello:
There are a series of textboxes (x.text, y.text, z.text etc.) in which user input is expected.
As:
dtmX=CDate(x.text)
dtmY=CDate(y.text)
dtmZ=CDate(z.text)
where x, y, and z.text must be in hh:mm format.
1. What is the best method for capturing hh:mm from a user? Ideally, I would like to use a control similar to the time input box in clock.exe, with the two up/down arrows that also uses the up/down keyboard keys, but without the seconds. What I don't want is the drop down calendar of the date timepicker with the single drop down arrow. How might that be accomplished?
2. I want the program to check for input errors (InvalidCastException ex: input of 24 hours or more in the hours part) and return to the textbox for user correction if an exception is caught, but not to keep executing the program until that correction has been accomplished, and then to test the box again, and then continue execution if the input is acceptable.
Try
dtmX = CDate(x.Text)
Catch ic As InvalidCastException
InputError()
Finally
txtX.Focus()
End Try
3. Using a Try/Catch/Finally the program will catch an input error in a textbox, but the program continues to execute beyond the subroutine, rather than returning to the textbox at position 1 and waiting for corrected input.
Should I use a do while or if loop or something similar to maintain flow control if I want the user to return to the box with the error for a user correction. Do I need a loop for each text box?
4. The Focus(), places the carat after the error instead at the beginning of the box (position 1). How do I get it to return to position 1, and return the box to the default condition prior to input?
5. Do I need to do a Try/Catch/Finally for each (of many) textboxes, or is there some simple way to iterate through them and stop only for an exception?
Thank You,
Dennis D.
There are a series of textboxes (x.text, y.text, z.text etc.) in which user input is expected.
As:
dtmX=CDate(x.text)
dtmY=CDate(y.text)
dtmZ=CDate(z.text)
where x, y, and z.text must be in hh:mm format.
1. What is the best method for capturing hh:mm from a user? Ideally, I would like to use a control similar to the time input box in clock.exe, with the two up/down arrows that also uses the up/down keyboard keys, but without the seconds. What I don't want is the drop down calendar of the date timepicker with the single drop down arrow. How might that be accomplished?
2. I want the program to check for input errors (InvalidCastException ex: input of 24 hours or more in the hours part) and return to the textbox for user correction if an exception is caught, but not to keep executing the program until that correction has been accomplished, and then to test the box again, and then continue execution if the input is acceptable.
Try
dtmX = CDate(x.Text)
Catch ic As InvalidCastException
InputError()
Finally
txtX.Focus()
End Try
3. Using a Try/Catch/Finally the program will catch an input error in a textbox, but the program continues to execute beyond the subroutine, rather than returning to the textbox at position 1 and waiting for corrected input.
Should I use a do while or if loop or something similar to maintain flow control if I want the user to return to the box with the error for a user correction. Do I need a loop for each text box?
4. The Focus(), places the carat after the error instead at the beginning of the box (position 1). How do I get it to return to position 1, and return the box to the default condition prior to input?
5. Do I need to do a Try/Catch/Finally for each (of many) textboxes, or is there some simple way to iterate through them and stop only for an exception?
Thank You,
Dennis D.