TIMER,的定时intval属性啊,1为1/1000秒啊,要多少就多少啊

解决方案 »

  1.   

    不是啦,Timer的定时间隔太短啦,我要1小时,2小时或几个小时呢。
    谁要是有现成的源码就好啦。一定给分。
      

  2.   

    我靠,你可以用timer定时,把当前时间记录到数据库,再用timer控制用time得到当前时间,再比较当前时间和数据库的时间差多少啊!,绝对OK,我最长用间隔一月,都OK的啊,是一个自动记费系统,如有疑问,发我邮件啊
      

  3.   

    别急!你的办法不是有些麻烦嘛。有现成的API代码的,很方便,很好用。不过还是谢你对这个问题的支持
      

  4.   

    用timer了,intval设置的大些就可以了
      

  5.   

    You can use SetTimer API.To Create the Sample Project
    ----------------------------1. Start a new Standard EXE project in Visual Basic. Form1 is created by default.2. Add a TextBox and CommandButton to Form1.3. Add a module to the project by completing the following steps:   a. From the Project menu, click Add Module. The Add Module dialog box appears.   b. On the New tab, choose Module and click OK. A new module is added to your project.4. Copy the following code to the Code window of Module1:     
            Option Explicit         Declare Function SetTimer Lib "user32" _
                   (ByVal hwnd As Long, _
                   ByVal nIDEvent As Long, _
                   ByVal uElapse As Long, _
                   ByVal lpTimerFunc As Long) As Long         Declare Function KillTimer Lib "user32" _
                   (ByVal hwnd As Long, _
                   ByVal nIDEvent As Long) As Long         Global iCounter As Integer         Sub TimerProc(ByVal hwnd As Long, _
                            ByVal uMsg As Long, _
                            ByVal idEvent As Long, _
                            ByVal dwTime As Long)             iCounter = iCounter + 1
                 Form1.Text1.Text = CStr(iCounter)
             End Sub5. Copy the following code to the Code window of Form1:         Option Explicit
             Dim lngTimerID As Long
             Dim BlnTimer As Boolean         Private Sub Form_Load()
                BlnTimer = False
                Command1.Caption = "Start Timer"
             End Sub         Private Sub Command1_Click()
             'Starts and stops the timer.            If BlnTimer = False Then
                   lngTimerID = SetTimer(0, 0, 200, AddressOf TimerProc)
                   If lngTimerID = 0 Then
                     MsgBox "Timer not created. Ending Program"
                     Exit Sub
                   End If
                   BlnTimer = True
                   Command1.Caption = "Stop Timer"
                Else
                   lngTimerID = KillTimer(0, lngTimerID)
                   If lngTimerID = 0 Then
                      MsgBox "couldn't kill the timer"
                   End If
                   BlnTimer = False
                   Command1.Caption = "Start Timer"
                 End If         End Sub6. On the Run menu, click Start or press the F5 key to start the program. Click Start Timer to create a timer event. At each specified interval, the TextBox is updated with a new value. Click Stop Timer to stop the timer event.==========Since the parameter uElapse of SetTimer is UINT, it can meet your need.Best Regards,Parker Zhang.
      

  6.   

    paykun(小培) 的代码不错噢,试一下先。
      

  7.   

    How do you try it?Just wait for one or two hours?Good luck :)Parker Zhang.
      

  8.   

    Something to add,uElapse specifies the time-out value, in milliseconds. You can use a Long data type with a value of up to 2,147,483,647 milliseconds. Values beyond this limit result in a Run-time Error '6' Overflow.
    Parker Zhang.
      

  9.   

    'Module:
    Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)public sub Delay(byval nHour as Integer) 'nHour为小时
    sleep nHour*3600*1000
    end sub
      

  10.   

    Option Explicit         Declare Function SetTimer Lib "user32" _
                   (ByVal hwnd As Long, _
                   ByVal nIDEvent As Long, _
                   ByVal uElapse As Long, _
                   ByVal lpTimerFunc As Long) As Long         Declare Function KillTimer Lib "user32" _
                   (ByVal hwnd As Long, _
                   ByVal nIDEvent As Long) As Long         Global iCounter As Integer         Sub TimerProc(ByVal hwnd As Long, _
                            ByVal uMsg As Long, _
                            ByVal idEvent As Long, _
                            ByVal dwTime As Long)             iCounter = iCounter + 1
                 Form1.Text1.Text = CStr(iCounter)
             End Sub5. Copy the following code to the Code window of Form1:         Option Explicit
             Dim lngTimerID As Long
             Dim BlnTimer As Boolean         Private Sub Form_Load()
                BlnTimer = False
                Command1.Caption = "Start Timer"
             End Sub         Private Sub Command1_Click()
             'Starts and stops the timer.            If BlnTimer = False Then
                   lngTimerID = SetTimer(0, 0, 200, AddressOf TimerProc)
                   If lngTimerID = 0 Then
                     MsgBox "Timer not created. Ending Program"
                     Exit Sub
                   End If
                   BlnTimer = True
                   Command1.Caption = "Stop Timer"
                Else
                   lngTimerID = KillTimer(0, lngTimerID)
                   If lngTimerID = 0 Then
                      MsgBox "couldn't kill the timer"
                   End If
                   BlnTimer = False
                   Command1.Caption = "Start Timer"
                 End If         End Sub
    很好用。