hi.. is there any way to stop do event??? my program keeps on executing do events even it pass through an exit sub
Printable View
hi.. is there any way to stop do event??? my program keeps on executing do events even it pass through an exit sub
What do you mean? DoEvents doesn't really process it allows everything else to process? Is it a loop you are trying to stop?
instart=0
intend=32
While blnLoop = True
For intOsci = intStart To intEnd Step intStep
'Send2Remote(strUserID, cboOnline.Text, "motor1 " & intOsci + intStartAt))
Write("motor1 " & intOsci + intStartAt)
If intOsci + intStartAt = intEnd Then
intTemp = intEnd
intEnd = intStart
intStart = intTemp
intStep = -(intStep)
intStartAt = -(intStartAt)
'reverse
If intOsci - intStartAt = 0 Then
intStart = 0
intEnd = -(intEnd)
intStep = -(intStep)
intStartAt = -(intStartAt)
End If
End If
If objShaft = 0.0 Then
Write("motor1 0")
blnLoop = False
Exit Sub
End If
System.Threading.Thread.CurrentThread.Sleep(intInterval)
System.Windows.Forms.Application.DoEvents()
Next
End While
heres my loop.. i keeps on runinng because of the doevents
Hi,
Have a look at the following thread.
http://www.vbforums.com/showthread.p...hreadid=289949
Use the code suggested by Janis
I.E. place a button on your form which will vary the status of a boolean which is checked every time the loop is continued.
DoEvents can't keep your loop running. It probably keeps running because blnLoop never equals False. You should step through it and check the values.
Hi edneeis,
"It probably keeps running because blnLoop never equals False."
Whether or not blnLoop is fals, that will NOT affect his loop.
Hi dimonique,
When I referred you to the other thread a did not look at your code.
Your loop will only exit if objShaft = 0.0 (i.e. =0)
Now, I find it difficult to imagine any object equalling 0.0
objShaft COULD = Nothing but not 0.0
objShaft.Text COULD equal "0.0" but that is unlikely.
You could have created your own class with a property which might = 0.0, but you would have to refer to that property.
I'm just guessing but I hope it helps.