.ReadLine - VBScript


The “.ReadLine” command in VB Script allows you to read a single line of text from the standard input (usually the keyboard). It is primarily used for user input and data entry in scripts and interactive applications.


object.ReadLine( [prompt] )

| Parameter | Description |
| object | An object that represents the text stream to read from. |
| prompt | (Optional) A prompt to display before reading input. |




' Read a line of input from the user
Dim input
input = InputBox("Enter your name:")

' Read a line of input from a file
Set fileStream = CreateObject("Scripting.FileSystemObject").OpenTextFile("test.txt")
Dim line
line = fileStream.ReadLine

Common Issues

  • Incorrect object type: Ensure that the object you are using to read from is a text stream object (e.g., TextStream).
  • Empty input: If the user does not enter any input before pressing Enter, “.ReadLine” will return an empty string (““”).
  • Unexpected line endings: Be aware that line endings may vary based on the operating system or text file format.


“.ReadLine” can be combined with other commands for advanced tasks, such as:

  • User input validation: Use the “.ReadLine” command to prompt users for input and then validate it using regular expressions or other methods.
  • Interactive scripting: Integrate “.ReadLine” into scripts to create interactive applications that respond to user input.
  • InputBox: Displays a modal dialog box to prompt the user for input.
  • MsgBox: Displays a message box to the user.