does anyone know how to save data to disk in visual basic 6.
does anyone have the code to save data to disk in a program.
How to save things to disk in visual basic 6?
To read from a file in VB6, try this:
Private Sub Reading_Click()
Dim variable1 As String
Open "c:\My Documents\sample.txt" For Input As #1
Input #1, variable1
Text1.Text = variable1
Close #1
End Sub
--
To write to a file, try this:
Private Sub create_Click()
Dim intMsg As String
Dim StudentName As String
Open "c:\My Documents\sample.txt" For Output As #1
intMsg = MsgBox("File sample.txt opened")
StudentName = InputBox("Enter the student Name")
Print #1, StudentName
intMsg = MsgBox("Writing a" %26amp; StudentName %26amp; " to sample.txt ")
Close #1
intMsg = MsgBox("File sample.txt closed")
End Sub
Reply:The easiest way is to use the FileSystemObject through COM.
Another easy way is to use Input and such
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment