求教 VB删除TXT指定字符所在行的内容?
比如txt内容:1adklw
56defgh
9dgeszd
df4sgnh
15tedcg
...
要删除含有 “1”的所有行
执行后
56defgh
9dgeszd
df4sgnh
...
小弟菜鸟 刚学习VB 能帮忙写下代码吗?
[ 本帖最后由 z8571127 于 2010-10-9 01:10 编辑 ]
程序代码:Option Explicit
Sub Main()
Dim a() As Byte, v, o
Open App.Path & "\test.txt" For Binary As #1
If (LOF(1)) < &H3FFFF Then
ReDim a(1 To LOF(1)) As Byte
Get #1, , a
End If
Close #1
v = Split(StrConv(a, vbUnicode), vbCrLf)
o = Filter(v, "1", False)
Open App.Path & "\out.txt" For Output As #1
If IsEmpty(o) Then
Else
For Each v In o
'Write #1, v
Print #1, v
Next
End If
Close #1
End Sub