1个回答
展开全部
Private Sub Command1_Click()
Dim tx() As String, tmp As String, n As Integer
'首先将txt文件里面非空行的内容读进数组tx里
Open "d:\a.txt" For Input As #1
n = 0
Do While Not EOF(1)
Line Input #1, tmp
If tmp <> "" Then
ReDim Preserve tx(n)
tx(n) = tmp
n = n + 1
End If
Loop
Close #1
'然后就清空txt文件,把数组tx里面的内容写进去就可以了
Open "d:\a.txt" For Output As #2
Cls
For i = 0 To UBound(tx)
Print #2, tx(i)
Next
Close #2
'如果你是要将过滤了空行的内容读进文本框里面,那么:
For i = 0 To UBound(tx)
Text1.Text = Text1.Text & tx(i) & vbCrLf
Next
End Sub
Dim tx() As String, tmp As String, n As Integer
'首先将txt文件里面非空行的内容读进数组tx里
Open "d:\a.txt" For Input As #1
n = 0
Do While Not EOF(1)
Line Input #1, tmp
If tmp <> "" Then
ReDim Preserve tx(n)
tx(n) = tmp
n = n + 1
End If
Loop
Close #1
'然后就清空txt文件,把数组tx里面的内容写进去就可以了
Open "d:\a.txt" For Output As #2
Cls
For i = 0 To UBound(tx)
Print #2, tx(i)
Next
Close #2
'如果你是要将过滤了空行的内容读进文本框里面,那么:
For i = 0 To UBound(tx)
Text1.Text = Text1.Text & tx(i) & vbCrLf
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询