Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. create timer in class

create timer in class

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marc Soleda
    wrote on last edited by
    #1

    In VB2005, how can I dinamically create a Timer inside a class without using the control. I suppose that I have to use the System.Timers.Timer class but I don't know how to handle the Elapsed event. Thanks in advance, Marc Soleda

    ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

    M T 2 Replies Last reply
    0
    • M Marc Soleda

      In VB2005, how can I dinamically create a Timer inside a class without using the control. I suppose that I have to use the System.Timers.Timer class but I don't know how to handle the Elapsed event. Thanks in advance, Marc Soleda

      ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

      M Offline
      M Offline
      MatrixCoder
      wrote on last edited by
      #2

      Do you mean something like this?

      Private Sub TimerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim Timer1 As New System.Timers.Timer()
      AddHandler Timer1.Elapsed, AddressOf TimerEvent
      End Sub

      Private Shared Sub TimerEvent(source As Object, e As Timers.ElapsedEventArgs)
      MsgBox("Hello World!")
      End Sub


      Trinity: Neo... nobody has ever done this before. Neo: That's why it's going to work.

      1 Reply Last reply
      0
      • M Marc Soleda

        In VB2005, how can I dinamically create a Timer inside a class without using the control. I suppose that I have to use the System.Timers.Timer class but I don't know how to handle the Elapsed event. Thanks in advance, Marc Soleda

        ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

        T Offline
        T Offline
        TwoFaced
        wrote on last edited by
        #3

        Just declare it withevents. Example: Withevents tmr as new timer

        M 1 Reply Last reply
        0
        • T TwoFaced

          Just declare it withevents. Example: Withevents tmr as new timer

          M Offline
          M Offline
          Marc Soleda
          wrote on last edited by
          #4

          Yep thanks, I missed the WithEvents modifier.

          ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups