Share via


FileWidth 函式

更新:2007 年 11 月

為使用 FileOpen 函式所開啟的檔案指派輸出行寬度。

Public Sub FileWidth( _
      FileNumber As Integer, _
      RecordWidth As Integer _
)

參數

  • FileNumber
    必要項,任何有效的檔案號碼。

  • RecordWidth
    必要項,介於 0–255 之間 (含) 的數值運算式,表示新行開始前出現的字元數。如果 RecordWidth 等於 0,表示不限制行的長度。RecordWidth 的預設值為 0。

例外狀況

例外狀況類型

錯誤代碼

條件

IOException

52

FileNumber 不存在。

IOException

54

檔案模式無效。

如果將使用非結構化錯誤處理的 Visual Basic 6.0 應用程式升級,請參閱「錯誤代碼」資料行 (您可以將錯誤代碼與 Number 屬性 (Err 物件) 比對)。但是,請盡可能考慮以 Visual Basic 的結構化例外處理概觀 取代這類錯誤控制項。

備註

這個函式會使用 FileOpen 函式所開啟的檔案來指派輸出行寬度。

範例

這個範例使用 FileWidth 函式來設定檔案的輸出行寬度。

Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Output) ' Open file for output.
FileWidth(1, 5)   ' Set output line width to 5.
For i = 0 To 9   ' Loop 10 times.
   Print(1, Chr(48 + I))   ' Prints five characters per line.
Next
FileClose(1)   ' Close file.

智慧型裝置開發人員注意事項

不支援這個函式。

需求

命名空間 (Namespace)︰Microsoft.VisualBasic

**模組︰**FileSystem

組件:Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

參考

FileOpen 函式

Print、PrintLine 函式

IOException

其他資源

Visual Basic 中的檔案、目錄和磁碟機屬性