ALX
Well-known member
Sometimes I can get hung up on the simplest things....
I have many forms in my app that use repetitve loops. A single mousedown event on the form itself breaks the loop.
Now I have added one more form to my app using the same strategy as all the others, but for reasons that are a mystery to me, it requires 2 sequential mousedown events to break the loop. So, as a test, I wrote this simple example to figue out what was going on. I was suprised that it also requires 2 mousedown events to break the loop. Setting a breakpoint in "Form1_MouseDown" does not trap the 1st mousedown event for the form. Maybe I just need another set of eyes here....
This sample form needs just two labels, ("Label1" and "GoButton"). After clicking "GO", clicking anywhere on the form (other than the labels) SHOULD set Repeat to 0 and break the loop.
I have many forms in my app that use repetitve loops. A single mousedown event on the form itself breaks the loop.
Now I have added one more form to my app using the same strategy as all the others, but for reasons that are a mystery to me, it requires 2 sequential mousedown events to break the loop. So, as a test, I wrote this simple example to figue out what was going on. I was suprised that it also requires 2 mousedown events to break the loop. Setting a breakpoint in "Form1_MouseDown" does not trap the 1st mousedown event for the form. Maybe I just need another set of eyes here....
This sample form needs just two labels, ("Label1" and "GoButton"). After clicking "GO", clicking anywhere on the form (other than the labels) SHOULD set Repeat to 0 and break the loop.
VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Form1[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] C [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Int16[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Repeat [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Int16 = 0[/SIZE]
[SIZE=2][COLOR=#0000ff] Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] GoButtonClick([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] GoButton.Click[/SIZE]
[SIZE=2] Repeat = 1[/SIZE]
[SIZE=2] C = 1[/SIZE]
[SIZE=2] Go()[/SIZE]
[SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Go()[/SIZE]
[SIZE=2][COLOR=#0000ff] Do[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] C < Int16.MaxValue[/SIZE]
[SIZE=2] Label1.Text = C.ToString[/SIZE]
[SIZE=2] Application.DoEvents()[/SIZE]
[SIZE=2][COLOR=#0000ff] If[/COLOR][/SIZE][SIZE=2] Repeat = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2] C += 1[/SIZE]
[SIZE=2][COLOR=#0000ff] Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Form1_MouseDown([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.MouseEventArgs) _ [/SIZE]
[SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] M[/SIZE][SIZE=2][COLOR=#0000ff]e[/COLOR][/SIZE][SIZE=2].MouseDown[/SIZE]
[SIZE=2] Repeat = 0[/SIZE]
[SIZE=2][COLOR=#0000ff] End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]