'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
'Createlyrics
'Purpose:
'Create two text files in the folder.
'Demonstrate the following content
'-FileSystemObject. createtextfile
'-Textstream. writeline
'-Textstream. Write
'-Textstream. writeblanklines
'-Textstream. Close
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Sub createlyrics (folder)
Dim textstream
Set textstream = folder. createtextfile ("octopusgarden.txt ")
Textstream. Write ("Octopus 'garden") '. Note that this statement does not wrap into a file.
Textstream. writeline ("(by Ringo Starr )")
Textstream. writeblanklines (1)
Textstream. writeline ("I 'd like to be under the sea in an octopus 'garden in the shade ,")
Textstream. writeline ("he 'd let us in, knows where we 've ve been -- in his Octopus 'garden in the shade .")
Textstream. writeblanklines (2)
Textstream. Close
Set textstream = folder. createtextfile ("bathroomworkflow workflow TXT ")
Textstream. writeline ("she came in through the bathroom window (by Lennon/McCartney )")
Textstream. writeline ("")
Textstream. writeline ("she came in through the bathroom window protected by a silver spoon ")
Textstream. writeline ("but now she sucks her thumb and wanders by the banks of her own Lagoon ")
Textstream. writeblanklines (2)
Textstream. Close
End sub
'Getlyrics
'Purpose:
'Displays the content of the lyrics file.
'Demonstrate the following content
'-FileSystemObject. opentextfile
'-FileSystemObject. GetFile
'-Textstream. readall
'-Textstream. Close
'-File. openastextstream
'-Textstream. atendofstream
'-Textstream. Readline
'''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''
Function getlyrics (FSO)
Dim textstream
Dim s
Dim File
'You can use multiple methods to open a text file and read data from the file.
'Here we use two methods to open and read files:
Set textstream = FSO. opentextfile (testfilepath & "\ Beatles \ octopusgarden.txt", openfileforreading)
S = textstream. readall & newline
Textstream. Close
Set file = FSO. GetFile (testfilepath & "\ Beatles \ bathroom1_txt ")
Set textstream = file. openastextstream (openfileforreading)
Do while not textstream. atendofstream
S = S & textstream. Readline & newline
Loop
Textstream. Close
Getlyrics = s
End Function