I'm trying hard to solve that issue without any luck :(
Here is my code :
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private frm As Form
Public Sub GenerateForm()
Set frm = New myForm
With frm
.Width = 4000
.Height = 3000
.Caption = "Message"
End With
frm.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
frm.Show vbModal
Sleep 3000
Unload Me
Set frm = Nothing
End Sub
Private Sub Command1_Click()
GenerateForm
End Sub
I want to close the newly created form automatically after 3 seconds.
You could use the timer like this, once it reaches 3 seconds (3000) it will close the form and open another one.
Windows opened in modal mode wait for user input, so the statements after
will not execute.
.
You have two solutions:
a) remove vbModal
b) add Timer on myForm and set Interval to 1000 (mean 1 second), next add this code in Timer event:
Last, you should use
since Unload Me is wrong.