Howard, no problem at all. I've commented about a few lines below that I
thought would be the best for you, please let me know if you have any
other questions after these.
Dim iAttempts As Integer = 0
'iAttempts is simple a integer variable I plan to use to track the
'number of times the user has entered an invalid variable.
Do
'This part might be tricky, the Do...Loop encompasses everything
'the program does. This is necessary because when an invalid value
'is entered the program will fall to to the Catch, and then normally
'would fall to the end sub. In this setup, it will Loop back to the
top
'and ask the user for the value again.
Try
'Literally, all of the code we want to "try" and execute.
Catch strEx1 As Exception When iAttempts < 3
'Catch is new to VB and a great tool. You can have multiple catches
'in a program based on what types of execeptions you want to trap,
'or just a generic catch like this one. This catch tell the program
to
'execute the contained code when any exception is raised and when
'iAttempts is less than 3.
iAttempts += 1
'Since we are in the catch, an invalid value was obviously
'entered. We must increment iAttempts or risk an infinite loop.
Catch strEx2 As Exception
'This will catch all other errors, to include an invalid character
when
'iAttempts is greater than 4.
Exit Do
'This ensures if the program encounters an exception, or if it
'encounters the fourth invalid charactor.
End Try
'Required to close out the Try...Catch
Loop
'This is the loop to ensure continuance, as discussed above.
For more information in the abilities of the Try..Catch..Finally..End Try,
check this page out:
http://msdn.microsoft.com/library/de...tchFinally.asp
Hope this helps, let me know!
chrisj
"Howard" <ho**********@gmail.com> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
Thanks Chris,
I was wondering if you can explain a little bit on the newly added code.
I think I understand it, but not 100% positive on it.
Thanks again,
Howard
--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com