Results 1 to 6 of 6

Thread: is there any way to stop DoEvents

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    9

    is there any way to stop DoEvents

    hi.. is there any way to stop do event??? my program keeps on executing do events even it pass through an exit sub

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What do you mean? DoEvents doesn't really process it allows everything else to process? Is it a loop you are trying to stop?

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    9
    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

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.
    Last edited by taxes; May 15th, 2004 at 04:48 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width