首页 > 其他 > 详细

VB 删除txt文件的最后一行

时间:2017-07-14 20:58:18      阅读:659      评论:0      收藏:0      [点我收藏+]

Private Sub Command1_Click()
DelTxt App.Path & "\1.txt"
End Sub
Sub DelTxt(ByVal Path As String) ‘删除txt文件的最后一行
On Error GoTo eHandler:
Dim Fc As String, Fn() As String, I As Integer, Wjh As Integer
Wjh = FreeFile
Open Path For Binary As #Wjh
Fc = Space(LOF(Wjh))
Get #Wjh, , Fc
Close #Wjh
Fn = Split(Fc, vbCrLf)
ReDim Preserve Fn(UBound(Fn) - 1)
If UBound(Fn) <= 0 Then
Open Path For Output As #Wjh
Print vbNullString
Close #Wjh
Else
ReDim Preserve Fn(UBound(Fn) - 1)
Open Path For Output As #Wjh
For I = 0 To UBound(Fn)
Print #Wjh, Fn(I)
Next
Close #Wjh
End If
Exit Sub
eHandler:
Err.Clear
End Sub

VB 删除txt文件的最后一行

原文:http://www.cnblogs.com/zgwxm/p/7172078.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!