How do i unload a form after it has loaded and visible for 10 seconds.
Printable View
How do i unload a form after it has loaded and visible for 10 seconds.
Code:Private Sub Form_Load()
Form1.Visible = True
OpenedAt = Now
Do Until DateDiff("s", OpenedAt, Now) >= 10
DoEvents
Loop
Unload Form1
End Sub
Or you can use a Timer with the Interval set to 1000. (1 second)
[code]
Private Sub Timer1_Timer()
Static tCount
tCount = tCount + 1
If tCount = 10 Then Unload Me
End Sub
Im sure there are better ways, but im new and untill then maybe this will help.
First create a timer and form and module.
in module put
Global hours, mins, seconds as integer
then in form1_load put
hours = 0
mins = 0
seconds = 10
form1.timer1.enabled = true
(set interval on timer to 1000)
This will count down the timer in 10 seconds....now
in timer1 put
if seconds = 0 then
seconds = 59
if mins = 0 then
mins = 59
if hours = 0 then
form1.unload
else
hours = hours - 1
end if
else
mins = mins -1
end if
else seconds = seconds - 1
end if
if len(mins) < 2 then mins = "0" & mins
if len(seconds) <2 then seconds = "0" & seconds
label2.caption = hours & ":" & mins & ":" & seconds
end sub
Hope that works....kind of slopy, be sure to check for typo's if get a error...see ya
Create a label2 as well, this way you can see the 10 seconds count down to make sure its working.
Thats y my programs are so buggy, look at there code and look at mind, geesh all that extra work I do.... I can probably make opening up a text file 4 megz of source...hehe....oh well i tried.
Two other ways:
The first is accurate to 1ms, the second to 60ms
Code:'In declarations
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
'In code
t=gettickcount+10000
Do while t>gettickcount
doevents
loop
Code:t=timer+10
Do while t>timer
doevents
loop