vb txt 删除指定行
3个回答
展开全部
Private Sub Command1_Click()
Dim arr, i As Long, N As Long
If Dir("c:\123.txt") = "" Then Exit Sub
Open "c:\123.txt" For Input As #1
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
N = 2 '删除第2行
If UBound(arr) < N - 1 Then Exit Sub '没有N行
Open "c:\123.txt" For Output As #1
For i = 0 To UBound(arr)
If i <> N - 1 Then Print #1, arr(i)
Next
Close #1
End Sub
Dim arr, i As Long, N As Long
If Dir("c:\123.txt") = "" Then Exit Sub
Open "c:\123.txt" For Input As #1
arr = Split(StrConv(InputB(LOF(1), 1), vbUnicode), vbNewLine)
Close #1
N = 2 '删除第2行
If UBound(arr) < N - 1 Then Exit Sub '没有N行
Open "c:\123.txt" For Output As #1
For i = 0 To UBound(arr)
If i <> N - 1 Then Print #1, arr(i)
Next
Close #1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是txt文件?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询