小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

FileSystemObject的TextStream物件

 悟靜 2009-07-17
FileSystemObject的TextStream物件 - 小瓜瓜 [首頁]
●先由FileSystemObject來建立TextStream物件:
Private Sub Command1_Click()
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 8, True)
End Sub
●HTML、HTA下寫法一樣
<script language=vbscript>
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 8, True)
</script>
●ASP下寫法也一樣
<%
Set FSysObj = Server.CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 8, True)
%>

●建立好TextStream後,就可以對檔案做讀與寫的動作。
●說明:8指的是附加模式,2為覆蓋模式,1為讀檔模式,True指的是檔案若不存在則建立該檔案。

●TextStream.Write與TestStream.WriteLine:這兩個都是把資料寫到開起的檔案,只不過WriteLine寫完資料後會自動補上vbCrLf。

Private Sub Command1_Click()
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 2, True)
TStrmObj.Write "hi,"
TStrmObj.WriteLine "hello"
End Sub
●TextStream.Read、TestStream.ReadLine與TextStream:這三個都是把資料從檔案裡讀出來,Read是讀取某幾個字,ReadLine是讀取一行而ReadAll則是讀入整個檔案。
Private Sub Command1_Click()
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 1, True)
MsgBox TStrmObj.Read(2) '讀兩個字
End Sub
●TextStream.Read、TestStream.ReadLine與TextStream:這三個都是把資料從檔案裡讀出來,Read是讀取某幾個字,ReadLine是讀取一行而ReadAll則是讀入整個檔案。
<script language="vbscript">
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 1, True)
Document.Write Replace(TStrmObj.ReadAll,vbCrLf,"<br />") '整個檔案讀出來
</script>

●TextStream.AtEndOfStream可傳回是否已經(jīng)讀到檔尾:

Private Sub Command1_Click()
Set FSysObj = CreateObject("Scripting.FileSystemObject")
Set TStrmObj = FSysObj.OpenTextFile("C:\Test.txt", 1, True)
Do Until TStrmObj.AtEndOfStream = True
MsgBox TStrmObj.Read(1)
Loop
End Sub

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多