vb保存text
在TEXT1中,输入“123”之后保存,再次在TEXT1中输入“321”保存,使得保存的TXT文件是打开后是第一行321第二行123.也就是说每次保存的信息都在第一行。求...
在TEXT1中,输入“123”之后保存, 再次在TEXT1中输入“321”保存, 使得保存的TXT文件是打开后是 第一行321 第二行123. 也就是说 每次保存的信息都在第一行。求高手帮忙!
展开
3个回答
展开全部
楼上有误,始终在最后面
Private Sub Command1_Click()
Dim fn As String, s As String, newtxt As String
fn = "c:\1.dat"
Open fn For Input As #1
While Not .EOF
Input #1, s
newtxt = newtxt & s & vbCrLf
Wend
Close #1
newtxt = Text1.Text & vbCrLf & newtxt
Open fn For Binary As #1
Put #1, , newtxt
Close #1
End Sub
Private Sub Command1_Click()
Dim fn As String, s As String, newtxt As String
fn = "c:\1.dat"
Open fn For Input As #1
While Not .EOF
Input #1, s
newtxt = newtxt & s & vbCrLf
Wend
Close #1
newtxt = Text1.Text & vbCrLf & newtxt
Open fn For Binary As #1
Put #1, , newtxt
Close #1
End Sub
追问
While Not .EOF
此处会报错
追答
Private Sub Command1_Click()
Dim fn As String, s As String, newtxt As String
fn = "c:\1.dat"
Open fn For Input As #1
While Not EOF(1)
Input #1, s
newtxt = newtxt & s & vbCrLf
Wend
Close #1
newtxt = Text1.Text & vbCrLf & newtxt
Open fn For output As #1
Print #1, newtxt
Close #1
End Sub
展开全部
str1= .readall
str2="321"
str2=str2 & vbCrLf & str1
然后 .writeline str2
把 str2 写入不就行了
str2="321"
str2=str2 & vbCrLf & str1
然后 .writeline str2
把 str2 写入不就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Open AppPath For Append As #1
Print #1, Format(Time, "hh:mm:ss") & "==" & msg
Close #1
注意:AppPath为你保存的路径
Print #1, Format(Time, "hh:mm:ss") & "==" & msg
Close #1
注意:AppPath为你保存的路径
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询