Home All Groups Group Topic Archive Search About

Close a form after x amount of time

Author
5 Dec 2006 6:58 PM
mattgcon
I have a popup form within my application that I want to show for only
about 10 seconds. On this form by the way has an AVI that plays. I want
the form to popup on click of a button and close after 10 seconds
automatically but can't figure out how to do it, does nayone know how
to do this?

Author
5 Dec 2006 7:18 PM
RobinS
Add a timer to the form, set it for 10 seconds, when it
goes off, in your event handler, close the form.

Robin S.
--------------------------------------------
<mattg***@yahoo.com> wrote in message
Show quoteHide quote
news:1165345110.867115.245980@f1g2000cwa.googlegroups.com...
>I have a popup form within my application that I want to show for only
> about 10 seconds. On this form by the way has an AVI that plays. I want
> the form to popup on click of a button and close after 10 seconds
> automatically but can't figure out how to do it, does nayone know how
> to do this?
>
Author
5 Dec 2006 7:23 PM
mattgcon
Robin,

I tried the timer thing, I placed it within the form load maybe that is
the wrong place to have it, but anyway, after the time the form didn't
go away.

here is my code
                        t.Interval = 100
                        t.Enabled = True
                        While t.Interval < 10000
                            t.Interval += 100
                        End While
                        frmAVI.Close()





RobinS wrote:
Show quoteHide quote
> Add a timer to the form, set it for 10 seconds, when it
> goes off, in your event handler, close the form.
>
> Robin S.
> --------------------------------------------
> <mattg***@yahoo.com> wrote in message
> news:1165345110.867115.245980@f1g2000cwa.googlegroups.com...
> >I have a popup form within my application that I want to show for only
> > about 10 seconds. On this form by the way has an AVI that plays. I want
> > the form to popup on click of a button and close after 10 seconds
> > automatically but can't figure out how to do it, does nayone know how
> > to do this?
> >
Author
5 Dec 2006 7:22 PM
rowe_newsgroups
Here's one way using a timer:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Dim t As Timer = New Timer()
        t.Interval = 10000
        AddHandler t.Tick, AddressOf HandleTimerTick
        t.Start()
End Sub

Private Sub HandleTimerTick()
    Me.Close()
End Sub

Thanks,

Seth Rowe


mattg***@yahoo.com wrote:
Show quoteHide quote
> I have a popup form within my application that I want to show for only
> about 10 seconds. On this form by the way has an AVI that plays. I want
> the form to popup on click of a button and close after 10 seconds
> automatically but can't figure out how to do it, does nayone know how
> to do this?
Author
5 Dec 2006 7:22 PM
rowe_newsgroups
Here's one way using a timer:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        Dim t As Timer = New Timer()
        t.Interval = 10000
        AddHandler t.Tick, AddressOf HandleTimerTick
        t.Start()
End Sub

Private Sub HandleTimerTick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
    Me.Close()
End Sub

Thanks,

Seth Rowe


mattg***@yahoo.com wrote:
Show quoteHide quote
> I have a popup form within my application that I want to show for only
> about 10 seconds. On this form by the way has an AVI that plays. I want
> the form to popup on click of a button and close after 10 seconds
> automatically but can't figure out how to do it, does nayone know how
> to do this?
Author
5 Dec 2006 7:26 PM
lord.zoltar
mattg***@yahoo.com wrote:
> I have a popup form within my application that I want to show for only
> about 10 seconds. On this form by the way has an AVI that plays. I want
> the form to popup on click of a button and close after 10 seconds
> automatically but can't figure out how to do it, does nayone know how
> to do this?

So everyone else is suggesting Timers. I was going to suggest that as
well, but I wanted to be different! ;)
Is there a way you can detect when the AVI stops playing? If so, you
could detect the end of the AVI and then close the form. This *might*
be better than a fixed time limit of 10 seconds, in cases where the
system hangs for 1 or 2 seconds while the AVI is playing (actuallly,
probably while it's loading).
Unfortunately, I don't know how to do that in code (never done AVI's in
VB). But it's a different suggestiong.
Author
5 Dec 2006 7:31 PM
rowe_newsgroups
If he starts it as a process he could do:

dim p as System.Diagnostics.Process = Process.Start(..)
p.WaitfoExit()
me.Close()

I too have never messed with AVIs, hopefully the OP will share how he
starts it.

Thanks,

Seth Rowe


lord.zol***@gmail.com wrote:
Show quoteHide quote
> mattg***@yahoo.com wrote:
> > I have a popup form within my application that I want to show for only
> > about 10 seconds. On this form by the way has an AVI that plays. I want
> > the form to popup on click of a button and close after 10 seconds
> > automatically but can't figure out how to do it, does nayone know how
> > to do this?
>
> So everyone else is suggesting Timers. I was going to suggest that as
> well, but I wanted to be different! ;)
> Is there a way you can detect when the AVI stops playing? If so, you
> could detect the end of the AVI and then close the form. This *might*
> be better than a fixed time limit of 10 seconds, in cases where the
> system hangs for 1 or 2 seconds while the AVI is playing (actuallly,
> probably while it's loading).
> Unfortunately, I don't know how to do that in code (never done AVI's in
> VB). But it's a different suggestiong.
Author
5 Dec 2006 8:05 PM
mattgcon
Seth,

Actually I didn't do anything special to start the AVI. I am using an
Animation Control that automatically starts the AVI for me.
I did the timer thing like that which was mention and it work perfectly
thank you
rowe_newsgroups wrote:
Show quoteHide quote
> If he starts it as a process he could do:
>
> dim p as System.Diagnostics.Process = Process.Start(..)
> p.WaitfoExit()
> me.Close()
>
> I too have never messed with AVIs, hopefully the OP will share how he
> starts it.
>
> Thanks,
>
> Seth Rowe
>
>
> lord.zol***@gmail.com wrote:
> > mattg***@yahoo.com wrote:
> > > I have a popup form within my application that I want to show for only
> > > about 10 seconds. On this form by the way has an AVI that plays. I want
> > > the form to popup on click of a button and close after 10 seconds
> > > automatically but can't figure out how to do it, does nayone know how
> > > to do this?
> >
> > So everyone else is suggesting Timers. I was going to suggest that as
> > well, but I wanted to be different! ;)
> > Is there a way you can detect when the AVI stops playing? If so, you
> > could detect the end of the AVI and then close the form. This *might*
> > be better than a fixed time limit of 10 seconds, in cases where the
> > system hangs for 1 or 2 seconds while the AVI is playing (actuallly,
> > probably while it's loading).
> > Unfortunately, I don't know how to do that in code (never done AVI's in
> > VB). But it's a different suggestiong.
Author
5 Dec 2006 8:02 PM
Cor Ligthert [MVP]
Matt,

I find this a nice one,

http://www.vb-tips.com/dbpages.aspx?ID=e712f49d-7f54-4f59-945f-cfc96c6ca913

I hope this helps,

Cor

<mattg***@yahoo.com> schreef in bericht
Show quoteHide quote
news:1165345110.867115.245980@f1g2000cwa.googlegroups.com...
>I have a popup form within my application that I want to show for only
> about 10 seconds. On this form by the way has an AVI that plays. I want
> the form to popup on click of a button and close after 10 seconds
> automatically but can't figure out how to do it, does nayone know how
> to do this?
>