Print, PrintLine Procedures


Print, PrintLine Procedures

Class

Microsoft.VisualBasic.FileSystem

Syntax

     Print(fileNumber, output)     PrintLine(fileNumber[, output]) 


fileNumber (required; Integer)

Any valid file number of a file opened with FileOpen


output (required for Print ; any)

A comma-delimited list of expressions, or a ParamArray, to be written to the file

Description

The Print and PrintLine procedures output formatted data to a disk file opened in Append or Output mode. The PrintLine version also appends line termination characters.

In addition to standard data, output can include the SPC and TAB functions, discussed in their own entries in this chapter.

Usage at a Glance

  • The Print and PrintLine procedures use the locale settings for the system to format dates, times, and numbers.

  • The Print and PrintLine procedures are often used to output data in a human-readable format, not necessarily for reprocessing by a software application.

Example

The following code writes some simple formatted data using the PrintLine procedure and the TAB function.

     Dim fileID As Integer = FreeFile(  )     FileOpen(fileID, "c:\data.txt", OpenMode.Output, OpenAccess.Write)     PrintLine(fileID, "         1         2")     PrintLine(fileID, "12345678901234567890")     PrintLine(fileID, "--------------------")     PrintLine(fileID, 1, TAB(10), 10)     PrintLine(fileID, 100, TAB(10), 1000)     FileClose(fileID) 

This code generates the following output.

              1         2     12345678901234567890     --------------------      1        10      100      1000 

Version Differences

  • There are many syntactical differences between the VB 6 Print statement and the .NET Print procedure.

  • The PrintLine procedure is new with .NET as a partial replacement for the VB 6 Print statement.

  • In Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file-management features.

See Also

Write, WriteLine Procedures




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net