-
'createlyrics
' วัตถุประสงค์:
'สร้างไฟล์ข้อความสองไฟล์ในโฟลเดอร์
'แสดงสิ่งต่อไปนี้
' - filesystemobject.createtextfile
' - textStream.writeLine
' - textStream.write
' - textStream.writeBlanklines
' - textstream.close
-
Sub Createlyrics (โฟลเดอร์)
สลัวข้อความสตรีม
SET TEXTSTREAM = Folder.CreatetExtFile (Octopusgarden.txt)
TextStream.write (สวน Octopus ')' โปรดทราบว่าคำสั่งนี้ไม่ได้เพิ่มบรรทัดพันไว้ในไฟล์
TextStream.WriteLine ((โดย Ringo Starr))
TextStream.writeBlanklines (1)
Textstream.writeline (ฉันอยากอยู่ใต้ทะเลในสวนปลาหมึกยักษ์ในที่ร่ม)
TextStream.writeline (เขาขอให้เรารู้ว่าเราอยู่ที่ไหน - ในสวนปลาหมึกยักษ์ของเขาในที่ร่ม)
TextStream.writeBlanklines (2)
textstream.close
SET TEXTSTREAM = Folder.CreatetExtFile (BathroomWindow.txt)
TextStream.Writeline (เธอเข้ามาในหน้าต่างห้องน้ำ (โดย Lennon/McCartney)))
TextStream.WriteLine ()
TextStream.Writeline (เธอเข้ามาในหน้าต่างห้องน้ำที่ได้รับการปกป้องด้วยช้อนเงิน)
TextStream.writeline (แต่ตอนนี้เธอดูดนิ้วโป้งและเดินไปตามริมฝั่งทะเลสาบของเธอเอง)
TextStream.writeBlanklines (2)
textstream.close
สิ้นสุดย่อย
'Getlyrics
' วัตถุประสงค์:
'แสดงเนื้อหาของไฟล์เนื้อเพลง
'แสดงสิ่งต่อไปนี้
' - filesystemobject.opentextfile
' - filesystemobject.getFile
' - textStream.readall
' - textstream.close
' - file.openastextstream
' - textStream.atendofstream
' - textStream.readline
-
ฟังก์ชั่น getlyrics (FSO)
สลัวข้อความสตรีม
สลัว
หรี่ไฟล์
'มีหลายวิธีในการเปิดไฟล์ข้อความและหลายวิธีในการอ่านข้อมูลจากไฟล์
'นี่คือสองวิธีในการเปิดและอ่านไฟล์:
ตั้งค่า textStream = fso.opentextfile (testfilepath & /beatles/octopusgarden.txt, OpenFileForreading)
s = textStream.readall & newline & newLine
textstream.close
ตั้งค่าไฟล์ = fso.getFile (TestFilePath & /beatles/bathroomwindow.txt)
ตั้งค่า textStream = file.openastextstream (OpenFileForReading)
ทำในขณะที่ไม่ใช่ textstream.atendofstream
S = S & TextStream.readline และใหม่
วง
textstream.close
getlyrics = s
ฟังก์ชันสิ้นสุด