writing from file
To store the contents of variables in a sequential file, open it for sequential Output or Append, and then use the Print # statement. For example, a text editor might use the following line of code to copy the contents of a text box into a file:
Print #FileNum, TheBox.Text
Visual Basic also supports the Write # statement, which writes a list of numbers and/or string expressions to a file. It automatically separates each expression with a comma and puts quotation marks around string expressions:
Dim AnyString As String, AnyNumber As Integer
AnyString = "AnyCharacters"
AnyNumber = 23445
Write #FileNum, AnyString, AnyNumber
This code segment writes two expressions to the file specified by FileNum. The first contains a string and the second contains the number 23445. Therefore, Visual Basic writes the following characters (including all punctuation) to the file:
"AnyCharacters",23445
Note If you are using Write # and Input # with sequential access, consider using random or binary access instead, because they are better suited to record-oriented data.