Solved

Force a form redraw

Posted on 2008-10-30
4
1,442 Views
Last Modified: 2008-10-31
Is there a way in VBA to force a form to redraw?  It seems as my code is executing changing a control property like whether or not it's visible doesn't take effect until the code completely return and the form doesn't have anything else to do.  Jumping to a new function or using Sleep() doesn't get the form to refresh.

Thanks.
0
Comment
Question by:JohnSantaFe
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 22845971
In VB6, you typically use "DoEvents" to allow the form to process the pending refresh and update itself while staying inside your code block.

Not sure if you can use DoEvents in Excel...

    ...some code..
    DoEvents
    ...some more code..
0
 
LVL 11

Assisted Solution

by:thydzik
thydzik earned 250 total points
ID: 22846374
have a look at
UserForm1.Repaint

you may have to use
UserForm1.Show vbModeless
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 22847425
In VB6 most controls have a .Refresh function that can be called to force a repaint.
0
 

Author Comment

by:JohnSantaFe
ID: 22854511
Both Repaint and DoEvents seem to work equally well.

Didn't get a chance to try repaint.

Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now