Results 1 to 2 of 2

Thread: Questions on timer class and progressbar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2004
    Location
    west
    Posts
    96

    Questions on timer class and progressbar

    Hi everybody

    Below is a section of basic codes on how to use the timer class. May i know is there anyway i can implement a progressbar to indicate the 1 second interval for the timer class ? Thank you 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 in 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("Times Up!", "Timer")

    End Sub

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Questions on timer class and progressbar

    Something like this...
    VB Code:
    1. Private iKounter As Integer
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
    4.         Progressbar1.Max = 10
    5.         Progressbar1.Value = 0
    6.         Timer1.Interval = 1000
    7.         Timer1.Enabled = True
    8.         iKounter = 0
    9.     End Sub
    10.  
    11.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
    12.         Timer1.Enabled = False
    13.     End Sub
    14.  
    15.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    16.         iKounter = iKounter + 1
    17.         Progressbar1.Value = Progressbar1.Value + 1
    18.         If iKounter = 10 Then
    19.             Timer1.Enabled = False
    20.             MessageBox.Show("Your 10 seconds are up!", "Timer")
    21.         End If
    22.     End Sub
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width