O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Input Procedure

Class

Microsoft.VisualBasic.FileSystem

Syntax

Input(filenumber,value)
filenumber (required; Integer)

Any valid file number

value (required; any)

Data to read from file

Description

Reads delimited data from a file into variables. This statement is used to read files that were created using the Write procedure, in which case the items are comma delimited with quotation marks around strings.

Rules at a Glance

  • Data read by Input has usually been written using the Write procedure.

  • Use this statement with files that have been opened in Input or Binary mode only.

  • If value is numeric and the Input procedure encounters non-numeric data, an InvalidCastException exception occurs.

  • The Input procedure strips off the quotation marks that it finds around strings.

  • After the Input procedure reads value, it advances the file pointer to the next unread variable or, if the file contains no additional delimited data, to the end of the file.

  • If the end of the file is reached during the operation of the Input procedure, an error is generated.

  • The Input procedure assigns string or numeric data to value without modification. However, other types of data can be modified as shown in the following table:

    Data

    Value assigned to variable

    Delimiting comma or blank line

    “” (empty string)

    #TRUE# or #FALSE#

    True or False

    #yyyy-mm-dd hh:mm:ss#

    Date and/or time

    Note that #TRUE# and #FALSE# are case sensitive.

Example

If the file c:\data.txt contains the following data:

"one", "two", "three" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required