|
-
Feb 15th, 2005, 10:30 PM
#1
Thread Starter
Lively Member
Question on timer class
Hi everybody
I would like to ask a question on timer class........for example, the user clicks on the button, the timer starts to count for 1 sec and then i wish to hv a msgbox emerge to tell the user "no response" immediately after the 1 sec....... i would be appreciated if anyone can help me.......thank u very much
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
End Sub
-
Feb 16th, 2005, 01:13 AM
#2
Re: Question on timer class
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Timer1.Interval = 1000
Timer1.Enabled = True
'Do something if they respond ???
'
'If they respond in time turn off the timer?
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Times Up!", "Timer")
End Sub
Something similar to this.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 16th, 2005, 01:14 AM
#3
Re: Question on timer class
add a timer at design time, click on it and in properties set the interval to 1000 (milliseconds= 1 second).
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MsgBox("boo")
Timer1.Enabled = False
End Sub
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 16th, 2005, 01:19 AM
#4
Re: Question on timer class
But if they respond in the time allotted then the timer will still fire.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 16th, 2005, 01:24 AM
#5
Re: Question on timer class
 Originally Posted by RobDog888
But if they respond in the time allotted then the timer will still fire.
putting code in that commented area in button_click wont do anything unless he has an infinite loop, which is inefficient anyways
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 16th, 2005, 01:27 AM
#6
Re: Question on timer class
True , but I didnt know what other actions the poster had in place while he was waiting for a response.
Like an event for entering text in a textbox and pressing another button?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Feb 18th, 2005, 02:31 AM
#7
Thread Starter
Lively Member
Re: Question on timer class
hi Everybody
Thanks for the reply.....i'm have actually written a download process after the Timer1.Enabled = True and i wanted the timer to turn off if the download process complete on time.............but now.....i get this error "Handles clause requires a WithEvents variable"......what does this mean? can any 1 tell me this? thank u very much
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Timer1.Interval = 1000
Timer1.Enabled = True
'Do something if they respond ???
'
' If they respond on time turn off the timer
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Time out !!", "Timer")
End Sub
End Class
-
Feb 18th, 2005, 02:07 PM
#8
Re: Question on timer class
 Originally Posted by chioman
hi Everybody
Thanks for the reply.....i'm have actually written a download process after the Timer1.Enabled = True and i wanted the timer to turn off if the download process complete on time.............but now.....i get this error "Handles clause requires a WithEvents variable"......what does this mean? can any 1 tell me this? thank u very much
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Timer1.Interval = 1000
Timer1.Enabled = True
'Do something if they respond ???
'
' If they respond on time turn off the timer
Timer1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
MessageBox.Show("Time out !!", "Timer")
End Sub
End Class
that's probably because you copy/pasted the code hehe
You need to declare a variable first before you can reference an event for it. You can either do it manually, which I dont think would be easy for you..... .or
umm do this: you probably already have the button so the error should be from the timer. In design view of your form, add a TIMER control to your form and then double click on the timer. VS.NET will automatically generate the code for Timer_Tick event for you. Then you can put your timer code in there.
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|