Saving Data to disk

I need to save data, namely text, to disk. How do I do this. What command do I use?
R_N_WARDAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pit_Connect With a Mentor Commented:
The easiest way to save text to a file is to first, open a file on the disk, then write the text out, and then close the file.


Dim ff As Integer
Dim strFileName as String

ff = FreeFile
strFileName = "data.txt"

Open strFileName For Output As ff
Print #ff, strData
Print #ff, strData2
  ...
Close ff
0
 
danelroismanCommented:
'Save text into the file:
Dim number As Integer
number = FreeFile

Open "Text.txt" & MyIndex For Output As number
   Write #number, "This is a sample."
Close #number

0
 
R_N_WARDAuthor Commented:
Thank you.  A++.  Now could you tell me how to loud the data back to the textbox?
0
 
pit_Commented:
Pretty much the same way, except instead of opening the file for Output, open it for Input and use Input #ff, ...


ex.

Open strFileName For Input As ff
Input #ff, strData
Close

txtBox.Text = strData
0
 
R_N_WARDAuthor Commented:
Thanks for all the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.