Solved

When to use the Refresh method

Posted on 2003-12-08
6
255 Views
Last Modified: 2010-05-01
When does one know when to use the Refresh method of a form or control?  I've seen sample code where it's used quite a bit.  As a test, I've removed them and the application still seems to work fine.

Thanks.
0
Comment
Question by:halfondj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9898556
REfresh is used to forces a complete repaint of a form or control.


If you have do a lot inside the routine and you want to refresh the form or control, then you need to use refresh

ie.

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Text1.Text = Now
Text1.Refresh
Sleep 3000
End Sub


without the refresh the time will show 3 seconds later
0
 
LVL 5

Expert Comment

by:mccainz2
ID: 9898557
For example ,
I have a flexgrid which can have several 100 to 1000 items loaded into it ...If you have autoredraw=true then the grid will run extremely slow as it is trying to redraw itself every time any modification is made , in my case I am talking around 30 seconds ... If you turn autoredraw=false then the grid doesnt try to redraw itself until you call the refresh method when I am finished with all my updates to the grid...
0
 
LVL 5

Expert Comment

by:mccainz2
ID: 9898632
Arghh, Make that the redraw property rather....My memory played a trick on me , went back to verify and I was remembering redraw rather than refresh
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9901138
You need to use either Refresh or call DoEvents from within a looping structure that updates visual components during each iteration as VB does not update the screen until all code has completed.  Only do this if immediate feedback is required as it does slow down execution significantly.

Idle_Mind
0
 

Author Comment

by:halfondj
ID: 9903887
After setting the status bar, e.g.

     stbStatusBar.Panels(1).Text = "Ending communications session."

How would one refresh the status bar?  I get compile errors when trying:

    stbStatusBar.Panels(1).Text.Refresh

Thanks.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 9903994
Just

stbStatusBar.Refresh
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

696 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