引用:
原帖由 kkk 于 2007-7-20 15:06 发表 
在VB中启动“运行”按钮后更改text里的内容,当关闭程序时内容自动保存。请教各位前辈这种功能将如何实现? 
自动保存可以保存在文件里,当下次启动程序时再加载文件里的内容。
如下面代码
Private Sub Form_Load()
    If Dir("c:\1.txt") <> "" Then
        Text1.Text = ""
        Dim istr As String
        Open "c:\1.txt" For Input As #1
        Do Until EOF(1)
            Line Input #1, istr
            Text1.SelText = istr & vbCrLf
        Loop
        Text1.Text = Left(Text1.Text, Len(Text1.Text) - 2)
        Close #1
    End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Open "c:\1.txt" For Output As #1
    Print #1, Text1.Text
    Close #1
    
End Sub