Return to VBA Code Examples

VBA Line Input Statement

Line Input Description

Reads a single line from an Open sequential file and assigns it to a string.

Line Input Syntax

The Line Input statement contains 2 arguments:

FileNumber: Any valid file number.

VarName: Valid Varient or String variable name.

Examples of Excel VBA Line Input Statement

To test the Line Input Statement, create a text file “test.txt” on the D drive.(D:\test.txt) Assume that the content of the file is as following.

Please run the following code.

Then, the result will be as following.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users! vba save as


Learn More!