Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input text file

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
I have the following code:

Code:
  Dim FileName As String
  Dim fileNum As Integer
  Dim variable As String
  Dim inumber As Integer

  fileNum = FreeFile()
[green]  'Open Text File For Input[/green]
  Open FileName For Input As #fileNum
  
  Do While Seek(fileNum) <= LOF(fileNum)
[green]      'Store One Line Of Text From File To Variable[/green]
       Input #fileNum, variable
       MsgBox (variable)
[green] '.... more code ....[/green]
  Loop
This loads a single line from my text file in to a variable, however I have the following in my input file
Code:
  myVariable   myInteger

How can I load this into a variable and a number? i.e. so that
Code:
  variable = myVariable
  inumber  = myInteger
Thanks

Robert Cumming
 
shetlandbob,
after loading the line into 'variable' why not just split it into 2 (myVariable & myInteger)?
regards,
longhair
 
Input #filenumber takes a variable number of parameters therefore you could try (assuming file order is StringVar, IntVar):

Input #FileNum MyStringVar, MyIntVar [,etc, etc]

Hope this helps.

 
Sorry forgot a comma - should have been:

Input #FileNum, MyStringVar, MyIntVar [,etc, etc]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top