VB6Parse / Library / File Operations / width

VB6 Library Reference

Width Statement

Assigns an output line width to a file opened using the Open statement.

Syntax

Width #filenumber, width

Parts

Remarks

Examples

Basic Width Setting

Open "output.txt" For Output As #1
Width #1, 80
Print #1, "This output will wrap at 80 characters"
Close #1

Set Unlimited Width

Open "data.csv" For Output As #2
Width #2, 0  ' No line length limit
Print #2, LongDataString
Close #2

Width with Multiple Files

Open "narrow.txt" For Output As #1
Open "wide.txt" For Output As #2
Width #1, 40
Width #2, 120

Dynamic Width Setting

Dim lineWidth As Integer
lineWidth = 80
Open "report.txt" For Output As #1
Width #1, lineWidth

Width for Formatted Output

Open "report.txt" For Output As #1
Width #1, 80
Print #1, Tab(10); "Header"
Print #1, Tab(10); String$(50, "-")
Close #1

Common Patterns

Report Generation with Fixed Width

Sub GenerateReport()
Open "report.txt" For Output As #1
Width #1, 80

Print #1, "Annual Sales Report"
Print #1, String$(80, "=")
' ... report content ...

Close #1
End Sub

CSV Export (No Width Limit)

Sub ExportCSV()
Open "export.csv" For Output As #1
Width #1, 0  ' Allow unlimited line length

For i = 1 To RecordCount
Print #1, BuildCSVLine(i)
Next i

Close #1
End Sub

Console-Style Output

Open "console.log" For Output As #1
Width #1, 80  ' Standard console width
Print #1, "System Log - "; Now()
Close #1

← Back to File Operations | View all statements