在做删除txt文件中的内容是出现以下2个问题,请指教一下
这里我要删除123.txt中的4,但是里面有2个4,我希望按一次删除的文件未尾往上算起的第一个4,再按一次再往上一个4,依次类推。
现在我删除的123.txt中全部4,以下是代码:
Private Sub Form_Load()Open "d:\123.txt" For Input As #1 Dim st As String Dim qe As String Do Line Input #1, st If st <> "" Then qe = qe + vbCrLf + st End If Loop Until EOF(1) Text1.Text = qeClose #1End Sub
Private Sub Command1_Click()Open "d:\123.txt" For Input As #1 Dim st As String Dim qe As String Do Line Input #1, st If st <> Text2.Text And st <> "" Then qe = qe + vbCrLf + st End If Loop Until EOF(1) Text1.Text = qeClose #1
Open "d:\123.txt" For Output As #1 Seek #1, 1 Print #1, Text1.TextCloseEnd Sub
;上面的问题是:1、在text1.text中第一行总是出现一个空行
2、在删除时把text2.text中相同的全部删了。不符合题意。
请大佬们多指教一下,在每个新加或修改的地方用注释解释一下,万分感谢。