我有一个lorder  
是扫描一个指定文件是否存在,之前是不存在则发邮件。现在我要改成不存在间隔30秒再扫描一次,不存在再发邮件.请问怎么添加那段程序。

解决方案 »

  1.   

    用一个Timer去定时Check:Public Function FileExists(FileName As String) As Boolean' test to see if a file existsConst INVALID_HANDLE_VALUE = -1&
        
            FileExists = Not (GetFileAttributesW(StrPtr(FileName)) = INVALID_HANDLE_VALUE)
        
    End Function
      

  2.   

    加个timer控件:
    Private Sub Form_Load()
    Timer1.Interval = 30000
    Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
    '检测文件是否存在
    End Sub
      

  3.   

    原來的code是
    Public Function gint_CheckIfFileExists(str_AbsolutePath As String) As Integer'Return Value: 1 ボ郎
    '            : 0 ボ合盒硈絬タ盽, 郎ぃ
    '            : -1 ボ合盒硈絬ア毖    Dim str_FileName As String
        Dim str_PathVolume As String
        Dim str_ErrorDescription As String    On Error GoTo Error_Handler
        
            str_FileName = Dir(str_AbsolutePath, vbDirectory)
            
            If Left(str_AbsolutePath, 2) <> "\\" Then
                str_PathVolume = gstr_GetStringBeforeStringFromLeft(str_AbsolutePath, "\")
            ElseIf Left(str_AbsolutePath, 2) = "\\" Then
                str_PathVolume = gstr_GetStringBeforeStringFromRight(str_AbsolutePath, "\")
            End If
            
            If str_FileName <> "" Then
                gint_CheckIfFileExists = 1
            Else
            
                str_FileName = Dir(str_PathVolume, vbDirectory)
                
                If str_FileName <> "" Then
                    gint_CheckIfFileExists = 0
                Else
                    gint_CheckIfFileExists = -1
                End If
        
            End If
            
            Exit Function
    我要加呢,請指示.我要把TIMER控件加到哪裡
      

  4.   

    Private Sub Timer1_Timer()
    '检测文件是否存在
    End Sub里面部分怎么写.之前有检查文件的FUNCTION  我怎么调用.  调用完成后我还要返回结果,是不也应该是个function而不是sub  请指示
      

  5.   

    dim extRtn&
    Private Sub Timer1_Timer()
    '检测文件是否存在
    extRtn=gint_CheckIfFileExists(文件名)select case  extRtn
           case 1 '找到处理
              '...
           case 0 '未找到处理
              '...
           case -1 '-1处理
               '...
    end select
    End Sub
      

  6.   


    我運行提示Timer  variable not  defind 是怎麼回事  是沒定義嗎?我該咋定義
      

  7.   

    Private Sub Form_Load()
    Timer1.Interval = 30000
    Timer1.Enabled = True
    End Sub
    是這樣加嗎  可是我運行不行