Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
Line Input Statement
This standard VB statement reads a line from a sequential file into a string variable.
Syntax A
Line Input [#] filenumber, varName
Syntax B
Line Input [prompt,] varName
Returns
Not applicable
Usage
If it is included, the filenumber is the number used in the Open statement to open the file. If filenumber is not provided, the line is read from the keyboard.
If prompt is not provided, a question mark (?) is displayed as the prompt.
Line Input is used to read lines of text from a text file in which the data elements are separated by carriage returns. To read data from a file of comma-separated values, use Read.
Example
This example reads the contents of a sequential file line by line (to a carriage return) and displays the results. The second subprogram,
CreateFile
, creates the fileC:\temp001
used by the main subprogram.(general) (declarations)
Option Explicit
Declare Sub CreateFileSub CreateFile
Rem Put the numbers 1-10 into a file
Dim x as Integer
Open "c:\temp001" for Output as #1
For x = 1 to 10
Write #1, x
Next x
Close #1
End SubSub Button_Click
Dim testscore as String
Dim x
Dim y
Dim newline
Call CreateFile
Open "c:\temp001" for Input as #1
x = 1
newline = Chr(10)
msgtext = "The contents of c:\temp001 is: " & newline
Do Until x = Lof(1)
Line Input #1, testscore
x = x + 1
y = Seek(1)
If y>Lof(1) then
x = Lof(1)
Else
Seek 1,y
End If
msgtext = msgtext & testscore & newline
Loop
Close #1
Kill "c:\temp001"
End SubSee Also
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |