FileSystem.Print(Int32, Object[]) 方法

定義

將顯示格式的資料寫入序列檔案。

public:
 static void Print(int FileNumber, ... cli::array <System::Object ^> ^ Output);
public static void Print(int FileNumber, params object[] Output);
static member Print : int * obj[] -> unit
Public Sub Print (FileNumber As Integer, ParamArray Output As Object())

參數

FileNumber
Int32

必須的。 任何有效的檔案號碼。

Output
Object[]

Optional. 零個或多個逗號分隔的表達式寫入檔案。

Output參數設定如下:

T:System.IO.IOException: 檔案模式無效。

T:System.IO.IOExceptionFileNumber 不存在。

範例

這個範例使用 和 PrintPrintLine 函式來寫入檔案資料。

FileOpen(1, "c:\trash.txt", OpenMode.Output)   ' Open file for output.
Print(1, "This is a test.")   ' Print text to file.
PrintLine(1)   ' Print blank line to file.
PrintLine(1, "Zone 1", TAB(), "Zone 2")   ' Print in two print zones.
PrintLine(1, "Hello", "World")   ' Separate strings with a tab.
PrintLine(1, SPC(5), "5 leading spaces ")   ' Print five leading spaces.
PrintLine(1, TAB(10), "Hello")   ' Print word at column 10.

' Assign Boolean, Date, and Error values.
Dim aBool As Boolean
Dim aDate As DateTime
aBool = False
aDate = DateTime.Parse("February 12, 1969")

' Dates and booleans are translated using locale settings of your system.
PrintLine(1, aBool, " is a Boolean value")
PrintLine(1, aDate, " is a date")
FileClose(1)   ' Close file.

備註

PrintPrintLine 函式是為了向下相容而提供,可能會影響效能。 對於非傳統應用程式,物件 My.Computer.FileSystem 提供更好的效能。 欲了解更多資訊,請參閱檔案存取Visual Basic

Print 不包含行尾換行;不過,確實 PrintLine 包含換行畫面。

以 撰寫的資料 Print 通常透過 LineInputInput從檔案讀取。

若省略 OutputPrintLine則會印出一行空白行到檔案;對於 Print,則不輸出任何資料。 多個以逗號分隔的表達式會在譜邊界對齊,但若逗號混用, TAB 可能會導致結果不一致。

資料Boolean則會印出或FalseTrueTrue無論在哪裡,關鍵字False和關鍵字都不會被翻譯。

日期資料會依照系統識別的標準短日期格式寫入檔案。 當日期或時間成分缺失或為零時,僅寫入所提供的部分。

如果 Output 資料是空的,檔案不會寫入任何東西。 然而,如果Output列表資料為 ,DBNullNull則會寫入檔案。

對於 Error 資料,輸出為 Error errorcodeError無論地點為何,關鍵字均未被翻譯。

所有透過 使用 寫 Print 入檔案的資料皆具國際感知;也就是說,資料已使用適當的十進位分隔符正確格式化。 若使用者希望輸出多個地點使用的資料, Write 應使用。

使用 or PrintPrintLine 函式寫入檔案需要 Write 從列舉中 FileIOPermissionAccess 存取。 如需詳細資訊,請參閱FileIOPermissionAccess

適用於

另請參閱