'------------------------------------------------------------------'
Append : untuk menambah text di file text
output : untuk merubah seluruh isi file text
input : untuk membaca text di file text
- If its to make a new file but empty then use
Open App.Path & "\txtfile.txt" For Output As #1
Close #1
- But if its for deleting the file use
Kill App.Path & "\txtfile.txt"
'------------------------------------------------------------------'
Private Sub cmdsave_Click()
Dim filelocation As String
On Error Resume Next
' 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
Text1.Text = ""
End Sub
Private Sub cmdopen_Click()
Text1.Text = ""
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
Private Sub Form_Load()
Text1.Text = ""
End Sub
Tidak ada komentar:
Posting Komentar