0% found this document useful (0 votes)
393 views

Source Code Open & Save TXT Files

This Visual Basic code defines two procedures, one for saving text from a text box to a file and one for opening a file and loading its contents into a text box. The save procedure uses a common dialog box to select a file location, opens the file for appending, prints the text box contents to the file, and closes the file. The open procedure uses a common dialog box to select a file, opens the file for input, reads each line and adds it to the text box with a newline, and closes the file.

Uploaded by

Gilang On WP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
393 views

Source Code Open & Save TXT Files

This Visual Basic code defines two procedures, one for saving text from a text box to a file and one for opening a file and loading its contents into a text box. The save procedure uses a common dialog box to select a file location, opens the file for appending, prints the text box contents to the file, and closes the file. The open procedure uses a common dialog box to select a file, opens the file for input, reads each line and adds it to the text box with a newline, and closes the file.

Uploaded by

Gilang On WP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Private Sub cmdsave_Click()

Dim filelocation As String


' loads save as box
commondialog1.ShowSave
filelocation = commondialog1.FileName
' append saves over file if it assists
Open filelocation For Append As #1
Print #1, text1.text
Close #1
End Sub
Private Sub cmdopen_Click()
Dim filelocation As String
' show open box
commondialog1.ShowOpen
filelocation = commondialog1.FileName
' input files into text1.text
Open filelocation For Input As #1
Do Until EOF(1)
Input #1, Data
text1.text = text1.text + Data + vbNewLine
EOF (1)
Loop
Close #1
End Sub

You might also like