也是很常用 功能,如果每行前面有行號要移除,也用的到這個功能。
Private Sub detop_Click()
Open App.Path & "\log.txt" For Output As #1 '存到log.txt
Print #1, TxtMain 'strsql是變數名稱
Close #1
Dim a, i, intN
intN = InputBox("請輸入 n 的值", "請輸入 n 的值", 1)
Open App.Path & "\log.txt" For Input As #1 '載入 檔案 log.txt
While Not EOF(1)
Line Input #1, a
List1.AddItem a '增加list1.additem
Wend
Close #1
Open App.Path & "\log.txt" For Output As #2 '存到 log.txt
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
' Print #2, List1.Text
Print #2, Mid(List1.Text, intN + 1)
Next
Close #2
Open App.Path & "\log.txt" For Input As #1 '重新載入 檔案log.txt
TxtMain.Text = ""
List1.Clear
While Not EOF(1)
Line Input #1, a
TxtMain = TxtMain + a + vbCrLf '增加list1.additem
Wend
Close #1
End Sub