Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++, Visual Basic
Expertise: Beginner
Jun 7, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Use Refresh, Not DoEvents

When executing code and tying up the system, developers often use a label or status bar to display messages. If you simply assign your text or message to the control (for example, lblMsg.Caption = "Still working..."), you won't see the text because your code loop isn't allowing the form to respond to the message. To make the message visible, use the Refresh method of the control. Don't use the DoEvents command to refresh the text to the user-this introduces re-entrancy issues. Note that displaying messages slows down performance, so use them intelligently:

Private Sub Command1_Click()
	Dim J As Long
	For J = 1 To 1000
		Label1.Caption = "Message " & J
	Next J
End Sub
Joe Karbowski
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date