Please throw some light here....Me.Repaint [What does it actually do?]

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, below is my code which 'm intending to use as a progress indicator...it does not reflect quite as expected..

Thanks for helping in advance
Code:
[/FONT]
<TABLE style="WIDTH: 48pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=64><COLGROUP>[FONT=Courier New]<COL style="WIDTH: 48pt" width=64>[/FONT]<TBODY><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 48pt; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18 width=64>[FONT=Courier New][SIZE=2]Option Explicit[/SIZE][/FONT]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[FONT=Courier New][SIZE=2]Private Sub CommandButton1_Click()[/SIZE][/FONT]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Call dfxcb[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Run "Okies"[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Repaint[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Label1.Caption = "Please wait...for task1 to complete....."[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Run "okay"[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Repaint[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Label1.Caption = "Please wait...for task2 to complete....."[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Run "Okies"[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Repaint[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[SIZE=2][FONT=Courier New] Me.Label1.Caption = "All tasks Completed!"[/FONT][/SIZE]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[FONT=Courier New][SIZE=2]End Sub[/SIZE][/FONT]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[FONT=Courier New][SIZE=2]Sub dfxcb()[/SIZE][/FONT]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[FONT=Courier New][SIZE=2]Me.Label1.Caption = "Please wait..initializing task1"[/SIZE][/FONT]</TD></TR><TR style="HEIGHT: 13.5pt" height=18><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 13.5pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=18>[FONT=Courier New][SIZE=2]End Sub[/SIZE][/FONT]</TD></TR></TBODY></TABLE>
[FONT=Courier New]
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Me.Repaint is a message to the userform to repaint itself, in case it has been invalidated by actions such as: moving, resizing, regaining focus, etc...

What problems do you have specifically with your progress indicator?
 
Upvote 0
Before running any code I want to change the label caption to the action it is going to take....it does not repaint as i thought it should...

Is there a better way to do this?:)

Thanks again for helping
 
Upvote 0
How come the code in your first post is only shown in a small box, showing only two lines of code, where I have to scroll all the time? Really annoying...

Normally, you wouldn't need to use Repaint when changing a label caption. It should update by itself. Unless you currently are using Application.ScreenUpdating in a status of False, then you would need Repaint.

Could you try to edit your first post, so that the code is visible as a whole, that would make it easier to see what might be wrong in it...

Also, I am not really familiar with the 'Run "something" ' syntax... what does that do exactly?
 
Upvote 0
Sure...here's my current code;
'm using run because my code that 'm suppose to run is

provate sub okies() 'like that... :)

Thanks again....
Code:
[/FONT]
[FONT=Courier New]Option Explicit
Private Sub CommandButton1_Click()
 Call dfxcb
 Run "Okies"
 Me.Repaint
 Me.Label1.Caption = "Please wait.....123"
 Run "okay"
 Me.Repaint
 Me.Label1.Caption = "Please wait.....1234"
 Run "Okies"
 Me.Repaint
 Me.Label1.Caption = "Task Completed!"
End Sub
Sub dfxcb()
Me.Label1.Caption = "Please wait.....12"
End Sub
 
Upvote 0
Never seen the use of Run to call a simple Sub, why not just
Code:
Okies
or
Code:
Call Okies 'like you do with Call dfxcb
instead of
Code:
Run "Okies"

Try like this:

Code:
Option Explicit
Private Sub CommandButton1_Click()
 Me.Label1.Caption = "Please wait.....12"
 Me.Repaint
 Call Okies
 Me.Label1.Caption = "Please wait.....123"
 Me.Repaint
 Call okay
 Me.Label1.Caption = "Please wait.....1234"
 Me.Repaint
 Call Okies
 Me.Label1.Caption = "Task Completed!"
End Sub

The repaint should come after the label change, in your code it came before...
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top