每行開頭加入字串,在sql加上--就變註解
我還蠻常用到的功能,我用的是Mssql 2000
Private Sub TopAddString_Click()
Open App.Path & "\log.txt" For Output As #1 '存到c:\log.txt
Print #1, TxtMain 'strsql是變數名稱
Close #1
Dim a, i, StrWord
StrWord = InputBox("請輸入開頭要加入的字串", "請輸入開頭字串")
Open App.Path & "\log.txt" For Input As #1 '載入 檔案before.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 '存到c:\log.txt
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
' Print #2, List1.Text
'If Len(List1.Text) > 0 Then Print #2, Mid(List1.Text, 1, Len(List1.Text) - intN)
If Len(List1.Text) > 0 Then Print #2, StrWord + List1.Text
If List1.Text = "" Then Print #2, List1.Text
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