Click here to Skip to main content
16,019,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, I'm posting this again, I have a problem in timers, I want to display 3 forms each one after 3, 5 and 10 seconds, how to do that?

I mean when the first form appears, after 3 seconds another one will appear, then after 5 seconds the second will appear and finally after 10 seconds the another one will appear. I have a code where someone gave me here on Codeproject but its for message box only, thus I modify it to put a form still does not work. Here the code I put in the timer below:


VB
If iCount < 100 Then i4.Show()
        iCount = iCount + 1
        tmrnote.Stop()
Posted

You have to show the first form when iCount is equal to 3 (assuming your timer having period of 1 sec), the second one when it is equal to 5, the third one when it is equal to 10.
:-)
 
Share this answer
 
I take it that that code block is inside the timers elapsed event and so should be something like this

C#
switch(count)
    case 0:
        Form1.Show();
        tmrNote.Interval = 3;
        count +=1;
        break;
    case 1:
        Form2.Show();
        tmrNote.Interval = 5;
        count +=1;
        break;
    case 2:
        Form3.Show();
        tmrNote.Interval = 10;
        count +=1;
        break;
    case 3:
        Form4.Show();
        tmrNote.Stop;
        break;


This is really pseudo code, but you should get the idea.

Hope this helps.
 
Share this answer
 
Comments
555336 8-Apr-11 10:53am    
but my interval in the timer's properties will remain 100 as default right?
555336 8-Apr-11 11:05am    
here is my code, still have problem when the message box stops, it displays all the forms together. All I want is when the message box stops, then it display the first form then stop to display the second then stop to display the last. The first form must stay for 3 seconds on the screen, then after 3 seconds the second appears then after 5 seconds the last appears.


Private Sub frmblabla_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

tmrnote.Start()


Private Sub tmrnote_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrnote.Tick

Static iCount As Integer
If iCount < 10 Then MsgBox("I got you!", vbCritical, "LOL")
iCount = iCount + 1
tmrnote.Stop()
If iCount < 100 Then i1.Show()
iCount = iCount + 3
tmrnote.Stop()
If iCount < 100 Then i2.Show()
iCount = iCount + 5
tmrnote.Stop()
End Sub
End Class
Simon_Whale 8-Apr-11 17:10pm    
your telling the timer to stop after each step in the process remove "tmrnote.stop" and try it again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900