+ Reply to Thread
Results 1 to 4 of 4

Form Repainting Problem

  1. #1
    ybazizi
    Guest

    Form Repainting Problem

    I have a label on a form that I use to show the progress of a loop. It works
    great except if I change the focus to a different application and then return
    to excel. Doing so freezes the label where it was when I changed the focus.
    Is there a to get the form to start refreshing again?

    Thanks


    For i = 1 To LastRow
    lblStatus.Caption = i & " of " & LastRow
    frmStatus.Repaint
    ...the rest of the loop
    Next i


  2. #2
    Tom Ogilvy
    Guest

    Re: Form Repainting Problem

    Perhaps

    For i = 1 To LastRow
    lblStatus.Caption = i & " of " & LastRow
    frmStatus.Repaint
    doevents
    ...the rest of the loop
    Next i

    --
    Regards,
    Tom Ogilvy


    "ybazizi" <[email protected]> wrote in message
    news:[email protected]...
    > I have a label on a form that I use to show the progress of a loop. It

    works
    > great except if I change the focus to a different application and then

    return
    > to excel. Doing so freezes the label where it was when I changed the

    focus.
    > Is there a to get the form to start refreshing again?
    >
    > Thanks
    >
    >
    > For i = 1 To LastRow
    > lblStatus.Caption = i & " of " & LastRow
    > frmStatus.Repaint
    > ...the rest of the loop
    > Next i
    >




  3. #3
    Crowbar via OfficeKB.com
    Guest

    Re: Form Repainting Problem

    Don't know how useful this is but I found pausing the application works with
    things like this, this will pause the loop for half a second that usaully is
    more than enough time for the computer to refresh

    Dim PauseTime, Start, Finish

    For i = 1 To LastRow

    PauseTime = 0.5 ' Set duration.
    Start = Timer ' Set start time.
    Do While Timer < Start + PauseTime
    Loop
    Finish = Timer ' Set end time.

    lblStatus.Caption = i & " of " & LastRow
    frmStatus.Repaint
    ...the rest of the loop
    Next i

    --
    Message posted via OfficeKB.com
    http://www.officekb.com/Uwe/Forums.a...mming/200601/1

  4. #4
    ybazizi
    Guest

    Re: Form Repainting Problem

    The DoEvents did the trick. Thanks!

    "Tom Ogilvy" wrote:

    > Perhaps
    >
    > For i = 1 To LastRow
    > lblStatus.Caption = i & " of " & LastRow
    > frmStatus.Repaint
    > doevents
    > ...the rest of the loop
    > Next i
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "ybazizi" <[email protected]> wrote in message
    > news:[email protected]...
    > > I have a label on a form that I use to show the progress of a loop. It

    > works
    > > great except if I change the focus to a different application and then

    > return
    > > to excel. Doing so freezes the label where it was when I changed the

    > focus.
    > > Is there a to get the form to start refreshing again?
    > >
    > > Thanks
    > >
    > >
    > > For i = 1 To LastRow
    > > lblStatus.Caption = i & " of " & LastRow
    > > frmStatus.Repaint
    > > ...the rest of the loop
    > > Next i
    > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1