VBA Input text file

Verald

New Member
Joined
Oct 16, 2009
Messages
28
I am trying to read through a text file using the following code:

Dim id, buffer As String
Dim amount as Variant
Open "c:\mytext.txt" For Input Access Read As #1
While Not EOF(1)
Input #1, id, amount, buffer
[do other stuff]
Wend

The text file looks like:
784118879,1,YYYYMMDD
A6893408,1,YYYYMMDD
929M06201,1,YYYYMMDD
GENERAL,1,YYYMMDD

The above reads the input file correctly for all except the third line, where the field is a number followed by text. In that case it only reads the numbers until the first letter. (ie returns 929)

Any ideas what is going on?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top