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

前端之家收集整理的这篇文章主要介绍了VB 检测文件变化 并获取变化的数据前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
  2. Dim file_bytes As String
  3. '用于检测文件夹是否存在
  1.  
  1. Private Sub Command1_Click()
  2. Unload Me
  3. End Sub
  4.  
  5. Private Sub Command2_Click()
  6. Label2(1).Caption = ""
  7. End Sub
  8.  
  9. Private Sub Form_Load()
  10. Label5.Caption = ALL_PATH
  11. Dim FS,F As String,FL As String
  12. Set FS = CreateObject("Scripting.FileSystemObject")
  13. If FS.FileExists(ALL_PATH) = True Then
  14. Label6.Caption = "Have test data!"
  15. Dim Out As String
  16. Out = "File size: " & FileLen(ALL_PATH) & "bytes"
  17. file_bytes = FileLen(ALL_PATH)
  18. Label7.Caption = Out
  19. Else
  20. Label6.Caption = "No test data!"
  21. End If
  22. Call check_update '檢測是否更新了
  23. End Sub
  1.  
  1.  
  1. '根据文件大小变化判断是否变化
  2. Private Function check_update()
  3. Do While file_bytes = FileLen(ALL_PATH)
  4. DoEvents
  5. Loop
  6. file_bytes = FileLen(ALL_PATH)
  7. Call loade_data
  8. End Function
  1.  
  1.  
  1. '循环到文件最后并提取数据
  2. Private Function loade_data()
  3. Dim gotline As String
  4. Dim NUM,RESULT As String
  5. Dim ARR
  6. Open ALL_PATH For Input As #4
  7. Do While Not EOF(4)
  8. Line Input #4,gotline
  9. Loop
  10. Close #4
  11. ARR = Split(gotline,";",-1,1)
  12. NUM = ARR(4)
  13. RESULT = ARR(5)
  14. Label2(1).Caption = "CH " & NUM & " " & RESULT
  15. Call check_update
  16. End Function

猜你在找的VB相关文章