Re: Using On Error to Exit Loop...ok?
- From: "Rick Rothstein" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Oct 2009 01:36:42 -0400
Is this good and acceptable programming practice to
use "On Error GoTo.." as a way to exit a loop?
I don't like it.
On Error GoTo Found
Do While PictureBox1(free).Visible
free = free + 1
Loop
You can use this code to find the lowest unused Index value for your PictureBox1 control array without resorting to error trapping...
Dim S As String, C As Control, Free As Long
If PictureBox1.LBound = 0 Then
S = Space$(PictureBox1.UBound + 1)
For Each C In Controls
If TypeOf C Is PictureBox Then Mid(S, C.Index + 1, 1) = "X"
Next
Free = InStr(S, " ") - 1
End If
MsgBox "Lowest unused Index value = " & Free
--
Rick (MVP - Excel)
.
- Follow-Ups:
- Re: Using On Error to Exit Loop...ok?
- From: Larry Serflaten
- Re: Using On Error to Exit Loop...ok?
- From: Webbiz
- Re: Using On Error to Exit Loop...ok?
- References:
- Using On Error to Exit Loop...ok?
- From: Webbiz
- Using On Error to Exit Loop...ok?
- Prev by Date: Re: Using On Error to Exit Loop...ok?
- Next by Date: Containers and Such
- Previous by thread: Re: Using On Error to Exit Loop...ok?
- Next by thread: Re: Using On Error to Exit Loop...ok?
- Index(es):
Relevant Pages
|