Saturday, April 20, 2019

VBA - Create a time delay before unloading User Form

create delay to unload VBA userform;VBA;VBA unload userform delay;create 5 seconds before unload userform


I had a requirement to unload an VBA user form after few seconds delay, that I used to display progress of the tasks.

Solution:


You may try the below:

Application.Wait Now + TimeValue("0:00:03") 'Create a time delay of 3 seconds

Sample Code:

FrmProgress.Label1.Caption = "Loading data from database...."
FrmProgress.Show
FrmProgress.Repaint

'...code for whatever it is you want to do

Application.Wait Now + TimeValue("0:00:03") 'Create a time delay

Unload FrmProgress
Sample Code 2:

MsgBox "Running Script in Database...Please Wait..", vbInformation, "In-Progress"Wait (5)MsgBox "Script Executed Successfully!", vbInformation, "Execution Completed" Sub Wait(seconds As Integer)      Dim now As Long      now = Timer()      Do          DoEvents      Loop While (Timer < now + seconds)    End Sub


5 comments:

  1. Thanks for the incredibly helpful contents ! Very cool blog to rewatch. It is nice to read such high-quality content. Attractive information on your blog on Windows Versions. I am happy to be your newest follower. I would love hop over and visit your blog whenever get a chance. Keep up the good work.

    ReplyDelete
  2. Great articles, first of all Thanks for writing such lovely Post! Other wise If any one who want to learn dot-net contact us on 9311002620 or visit:- https://htsindia.com/Courses/microsoft-courses/dotnettraininginstituteinsouthdelhi

    ReplyDelete
  3. Thanks for providing awesome article about DotNet. I hope you will keep it up.

    ReplyDelete
  4. https://www.uwptutorials.com/uwpxamlcontrols.html

    ReplyDelete