|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Newbe question, What am I doing wrongI have two questions the first is: in the example below how can I call an event from within a statement, such as replace Stop1 with cmdStop1 which is a button on my form? My second question again deals with the example below. Shouldn't I see the valve of " i" counting away in the txtCount1 text box? I don't see anything in the text box and would like to know what I'm doing wrong. Thanks in advance for any and all help. Regards, Ken Stop1 = 0 Do For i As Integer = 1 To 10 txtCount1.Text = i If Stop1 = 1 Then Exit Do End If Next i Loop End Sub "ken" <somewere@out.there> schrieb You can not call an event. Either /raise/ an event or /handle/ it.> Hi, > I have two questions the first is: in the example below how can I > call an event from within a statement, such as replace Stop1 with > cmdStop1 which is a button on my form? Show quoteHide quote > My second question again deals with the example below. Shouldn't I The textbox doesn't update because there is no time. There is not time> see the valve of " i" counting away in the txtCount1 text box? I > don't see anything in the text box and would like to know what I'm > doing wrong. Thanks in advance for any and all help. > Regards, > Ken > > > > Stop1 = 0 > Do > For i As Integer = 1 To 10 > txtCount1.Text = i > If Stop1 = 1 Then > Exit Do > End If > Next i > Loop > End Sub because the loop is running. If you update a control, the rectangle on the screen is added to a list of invalid areas. The screen is (usually) not updated immediatelly. As soon as there is time, Win sends a message to the control (called WM_PAINT). Whenever the control receives this messages, it paints itself. The message can not be handled before your sub returns. To update the control immediatelly, call it's refresh method: txtcount1.refresh. This /forces/ the immediate repaint of the control. Be aware of a problem existing in WinXP (3rd paragraph): http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/aboutmessagesandmessagequeues.asp This means, even in a tiny program, you are forced to use a second thread to run the loop (or use application.doevents with all it's side-effects). A work-around is to call the API function Peekmessage within the loop (in addition to calling refresh). Armin Armin,
Thank you for answering my questions. I suspected that loop was happening to fast to update. Once again thanks. Ken Button1.PerformClick
-- Show quoteHide quoteDennis in Houston "ken" wrote: > Armin, > Thank you for answering my questions. I suspected that loop was > happening to fast to update. Once again thanks. > Ken > Hi Dennis and thanks, What I was trying to say is how can I check if a
Button has been Clicked from within a Loop. Ken For one thing, the button Click event won't fire until your loop finishes
unless you have a "DoEvents" statement within your loop or the loop is executing on a NON-UI thread. If you put a "DoEVents" statement withing your loop, you can use a boolean variable which scoped for access both in the button click event handler and the loop. Set the variable to False before the loop starts then set it to true in the button click event handler and check it after the DoEvents Statement in your loop. Hope this helps. -- Show quoteHide quoteDennis in Houston "ken" wrote: > Hi Dennis and thanks, What I was trying to say is how can I check if a > Button has been Clicked from within a Loop. > Ken >
beginner question about classes
Excel Range will not put data into correct Cell Best approach - databound controls & ADO.NET Selecting combobox item at runtime from code No Beep with MSGBOX Possible? Help Needed in bindings, Convert Byte() to System.Drawing.Image? OT: Business Objects - what are they and can they contain objects like sockets? Cache problem string formatting |
|||||||||||||||||||||||