改下~~~~~~~~~~~Open App.Path & "\out5.txt" For Append As #1
Open App.Path & "\out5.txt" For Output As #1 print #1,"" '''''''''''空一行應該就可以了吧,難道是我沒理解題目意思? print #1, text1.text Close #1
帮你找到一个获取文本行数的函数 如果要再任意行插入估计还要利用到其他API函数了! Const WM_USER = &H400 Const EM_GETLINECOUNT = WM_USER + 10#If Win32 ThenPrivate Declare Function SendMessage Lib "user32" _ Alias "SendMessageA" _ (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Integer, _ lParam As Any) As Long #ElsePrivate Declare Function SendMessage Lib "user" _ (ByVal hWnd As Integer, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ lParam As Any) As Long #End IfFunction TextLineCount(txtObj As TextBox) As Long If txtObj.MultiLine = True Then TextLineCount = SendMessage(txtObj.hWnd, EM_GETLINECOUNT, 0, 0&) Else TextLineCount = 1 End If End Function
print #1,"" '''''''''''空一行應該就可以了吧,難道是我沒理解題目意思?
print #1, text1.text
Close #1
如果要再任意行插入估计还要利用到其他API函数了!
Const WM_USER = &H400
Const EM_GETLINECOUNT = WM_USER + 10#If Win32 ThenPrivate Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Integer, _
lParam As Any) As Long
#ElsePrivate Declare Function SendMessage Lib "user" _
(ByVal hWnd As Integer, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
lParam As Any) As Long
#End IfFunction TextLineCount(txtObj As TextBox) As Long
If txtObj.MultiLine = True Then
TextLineCount = SendMessage(txtObj.hWnd, EM_GETLINECOUNT, 0, 0&)
Else
TextLineCount = 1
End If
End Function
用append则只能在最后添加
对于顺序文件,我看你只能读出文件所有内容,然后修改第二行(你想改的行数),再写入