?
Solved

When to use the Refresh method

Posted on 2003-12-08
6
Medium Priority
?
258 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
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!

 
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 1000 total points
ID: 9903994
Just

stbStatusBar.Refresh
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

762 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