VB 检测文件变化 并获取变化的数据

Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
Dim file_bytes As String
'用于检测文件夹是否存在
 
Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()
Label2(1).Caption = ""
End Sub

Private Sub Form_Load()
Label5.Caption = ALL_PATH
Dim FS,F As String,FL As String
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(ALL_PATH) = True Then
    Label6.Caption = "Have test data!"
    Dim Out As String
    Out = "File size: " & FileLen(ALL_PATH) & "bytes"
    file_bytes = FileLen(ALL_PATH)
    Label7.Caption = Out
Else
    Label6.Caption = "No test data!"
End If
Call check_update  '檢測是否更新了
End Sub
 
 
'根据文件大小变化判断是否变化
Private Function check_update()
      do while file_bytes = FileLen(ALL_PATH)
         DoEvents
      Loop
      file_bytes = FileLen(ALL_PATH)
      Call loade_data
End Function
 
 
'循环到文件最后并提取数据
Private Function loade_data()
Dim gotline As String
Dim NUM,RESULT As String
Dim ARR
Open ALL_PATH For Input As #4
            do while Not EOF(4)
               Line Input #4,gotline
            Loop
        Close #4
ARR = Split(gotline,";",-1,1)
NUM = ARR(4)
RESULT = ARR(5)
Label2(1).Caption = "CH  " & NUM & "  " & RESULT
Call check_update
End Function

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...