Private Sub Command1_Click() Dim strLine As String, strItems() As String Open "c:\test\1.txt" For Input As #1 Open "c:\test\2.txt" For Output As #2 Do Until EOF(1) Line Input #1, strLine strItems = Split(Trim(strLine), " ") If UBound(strItems) = 2 Then If strItems(1) = "8:00:00" Then strLine = Format(strItems(0), "yyyymmdd") & Format(strItems(1), "HH") & " " & strItems(2) Print #2, strLine End If End If Loop Close #2 Close #1 End Sub 2007070908 24.916 2007071008 24.851
哦?需求变了?Private Sub Command1_Click() Dim strLine As String, strItems() As String Open "c:\test\1.txt" For Input As #1 Open "c:\test\2.txt" For Output As #2 Do Until EOF(1) Line Input #1, strLine strItems = Split(Trim(strLine), " ") 'If UBound(strItems) = 2 Then If strItems(1) = "8:00:00" Then strLine = Format(strItems(0), "yyyymmdd") & Format(strItems(1), "HH") & " " & strItems(UBound(strItems)) Print #2, strLine End If 'End If Loop Close #2 Close #1End Sub
Dim strLine As String, strItems() As String Open "c:\test\1.txt" For Input As #1
Open "c:\test\2.txt" For Output As #2
Do Until EOF(1)
Line Input #1, strLine
strItems = Split(Trim(strLine), " ")
If UBound(strItems) = 2 Then
If strItems(1) = "8:00:00" Then
strLine = Format(strItems(0), "yyyymmdd") & Format(strItems(1), "HH") & " " & strItems(2)
Print #2, strLine
End If
End If
Loop
Close #2
Close #1
End Sub
2007070908 24.916
2007071008 24.851
Dim strLine As String, strItems() As String Open "c:\test\1.txt" For Input As #1
Open "c:\test\2.txt" For Output As #2
Do Until EOF(1)
Line Input #1, strLine
strItems = Split(Trim(strLine), " ")
'If UBound(strItems) = 2 Then
If strItems(1) = "8:00:00" Then
strLine = Format(strItems(0), "yyyymmdd") & Format(strItems(1), "HH") & " " & strItems(UBound(strItems))
Print #2, strLine
End If
'End If
Loop
Close #2
Close #1End Sub