VB 检测文件变化 并获取变化的数据
发布时间:2020-12-16 22:41:18 所属栏目:大数据 来源:网络整理
导读:Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As LongDim file_bytes As String'用于检测文件夹是否存在 Private Sub Command1_Click()Unload MeEnd SubPrivate Sub Command2_Click()Labe
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |