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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Past End of File!! Please Help

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Below is my code and the error is " Input past end of file. I donno much coding, kindly help me with right code.
Option Explicit

Dim strFile As String
Dim i As Integer
Public af0, af1, af2, A, c, check_t, cosecc, cuc, cus, crc, crs, cic, cis, deltan, E, ecc, dE, Em, E_old, i0, ik, idot, j, k, l, M, M0, n, n0, omega, Omega_new, Omega0, Omegadot, phi, phi_rem, q, r, svprn, satp11, satp21, satp31, roota, t, toc_Year, toc_Month, toc_Day, toc_Hour, toc_Minute, toc_Second, svcd, svbs, svcdd, IODE, tk, toe, toc, u, v, X1, Y1, z, z1, z11, z12, z13, z14, z15, z16, z17 As Double

Private Sub cmdcalc_Click()

Open strFile For Input As #1
Do While Not EOF(1)

Input #1, svprn, toc_Year, toc_Month, toc_Day, toc_Hour, toc_Minute, toc_Second, svbs, svcd, svcdd, IODE, crs, deltan, M0, cuc, ecc, cus, roota, toe, cic, Omega0, cis, i0, crc, omega, Omegadot, idot, z1, z11, z12, z13, z14, z15, z16,z17, 18
Loop
Close #1
****************************************
I have 35 items in my text file( They are values), so I declared 35 variables giing each one certain values.

Thanks
 
Hi Code_novice,

...I have 35 items in my text file( They are values), so I declared 35 variables giing each one certain values. ???

Your Input #1 actually lists 36 variables, if you only have 35 in the file this would generate an error message.

If you are going to read all 35 at once, I doubt that you need the loop

Jon
 
Dear jon,
now I made it to 35 items removing the 18, still its giving me the same error.
I dont need all the 35 values, infact I need only 17 values which are scattered in it. i.e I nee like 1,3,7,9.11,15,16 ... so on and out of these I need 17 values for my calc:
Can U help me

Laks
 
do a keyword search on this error, I had the same problem recently and there were several threads that were helpful
 
Hi Code_novice

How about reading all the values into an array ?

Dim intCount as integer
Dim dblMyVar as double
Dim dblArr(35) as double
Dim strFile as string
...
intCount = 0
Open strFile for Input as #1
while (not eof(1))
Input #1, dblMyVar
dblArr(intCount) = dblMyVar
intCount = intCount + 1
wend

This way you load all your values in an array then you can pick and choose which ones you want

Jon
 
Hi!! Jon,
That was agreat help!! I was looking for this kinda help. But it is giving me a Filepath error. I have used DialogBox to Open Files and the code for it is
dlgCommon.Filter = "Text Files(*.txt)|*.txt|All Files (*.*)|*.*"

dlgCommon.FileName = " "

dlgCommon.ShowOpen
strFile = dlgCommon.FileName

Is there anything wrong


Once agin thanks alot!!!!
 
Laks

On the surface it looks alright,at runtime the FileName property is set to a zero-length string (""), meaning no file is currently selected. So I don't think you need the command
dlgCommon.FileName = " "
You could try printing the path to the form to see what you get..
debug.print strFile

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top