by Dennis John (3 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 18th January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Read and Write a file(Notpad) through VB
'Create a txt document in desktop named "Text.txt"
'Add a command button and a textbox
'Set" multiline = true" of textbox
Private Sub Command1_Click()
Open "C:\WINDOWS\Desktop\Text.txt" For Output As #1
Print #1, Text1.Text
Close #1
chg = 0
End Sub
Private Sub Form_Activate()
On Erorr GoTo fileError
Open "C:\WINDOWS\Desktop\Text.txt" For Input As #1
Text1.Text = Input$(LOF(1), 1)
Close #1
Exit Sub
fileError:
MsgBox " Error"
End Sub