Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel VB Language Reference > Siebel VB Language Reference >
Input Statement
This standard VB statement reads data from a sequential file and assigns the data to variables.
Syntax
Input [#]filenumber, variable[, variable]...
Argument Description filenumber The file number used in the Open statement to open the file from which to read variable One or more variables to contain the values read from the file
Returns
Not applicable
Usage
The filenumber is the number used in the Open statement to open the file. The list of variables is separated by commas.
Example
This example prompts a user for an account number, opens a file, searches for the account number, and displays the matching letter for that number. It uses the Input statement to increase the value of x and at the same time get the letter associated with each value. The second subprogram,
CreateFile
, creates the filec:\temp001
used by the main subprogram.(general) (declarations)
Option Explicit
Declare Sub CreateFileGlobal x as Integer
Global y(100) as StringSub CreateFile
' Put the numbers 1-10 and letters A-J into a file
Dim startletter
Open "c:\temp001" for Output as #1
startletter = 65
For x = 1 to 10
y(x) = Chr(startletter)
startletter = startletter + 1
Next x
For x = 1 to 10
Write #1, x,y(x)
Next x
Close #1
End SubSub Button2_Click
Dim acctno as Integer
Dim msgtext
Call CreateFile
start: acctno = 2
If acctno<1 Or acctno>10 then
Goto start:
End if
x = 1
Open "c:\temp001" for Input as #1
Do Until x = acctno
Input #1, x,y(x)
Loop
msgtext = "The letter for account number " & x & " is: " _
& y(x)
Close #1
Kill "C:\TEMP001"
End SubSee Also
Get Statement
Input Function
Line Input Statement
Open Statement
Write Statement
Bookshelf Home | Contents | Index | Search | PDF | ![]() ![]() ![]() ![]() |
Siebel VB Language Reference Published: 18 June 2003 |