timer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sagi
    New Member
    • Oct 2006
    • 12

    timer

    hi how can i set the program to wait 5 seconds befor calculating

    every time the function is called?

    thanks
  • rhbt63
    New Member
    • Feb 2007
    • 9

    #2
    In the general toolbar in vb there is a timer, it looks funny enough like a stop watch double click this it will then be added to your project.
    now double click the timer this will open up the form code window and set you up inside the timer routine place your code here.

    now go inside private sub form_load () vb will have named the timer 'Timer1' so enter the following code.

    Timer1.Interval =5000


    Timer1.Enable=t rue (Sorry forgot this part)

    this will give you a timer that will execute the code inside it once every 5secs

    hope it helps


    rab

    Comment

    • sagi
      New Member
      • Oct 2006
      • 12

      #3
      no, i want the program to wait 5 seconds, not to do something every 5 seconds
      thanks

      Comment

      • Esmael
        New Member
        • Feb 2007
        • 58

        #4
        Hi...

        somebody gave the answer already. All you have to do is insert that in your code.


        I dont know how you set-up your Timer to your program:
        This is only a sample...
        Just modify your program... i hope you'll get the idea.

        '************** *************** **********Start
        Dim rst As Double
        Private Sub Form_Click()
        Timer1.Enabled = True
        Timer1.Interval = 5000
        End Sub

        Private Sub Form_Load()
        Timer1.Enabled = False
        End Sub

        Private Sub Timer1_Timer()
        Timer1.Enabled = False
        Call Calculate(1, 2)
        MsgBox rst
        End Sub


        Public Function Calculate(A, B) As Double
        Calculate = A + B
        rst = Calculate
        End Function
        '************** *************** **********End

        GoodLuck

        Comment

        Working...