'添加drivelistbox,dirlistbox,filelistbox,commamdbutton各一个
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
File1.ListIndex = i
If Right(File1.FileName, 3) = "txt" Then zhzsucyg (Dir1.Path & IIf(Right(Dir1.Path, 1) = "\", "", "\") & File1.FileName)
Next
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path & IIf(Right(Dir1.Path, 1) = "\", "", "\")
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Function zhzsucyg(myFile As String)
Dim myStr As String, n As Integer
Open myFile For Binary As #1
myStr = Input(LOF(1), 1)
Close
myStr = StrReverse(myStr)
n = InStr(1, myStr, "。") '如果最后的句号是“.”,请把“。”换成“.”
myStr = Mid(myStr, n + 1)
myStr = StrReverse(myStr)
Open myFile For Output As #1
Print #1, myStr
Close
End Function
追问我用你的代码测试,包含最后一个句号后面的内容都去掉了。最后一个句号还是要保留的啊,只需要去掉它后面的内容。
追答把myStr = Mid(myStr, n + 1)
改为myStr = Mid(myStr, n )
本回答被提问者采纳