EOF FUNCTION

I have no idea why my eof function doesnt work

Page 1 of 1

6 Replies - 15604 Views - Last Post: 19 April 2007 - 06:38 PM Rate Topic: -----

#1 Mr Mooju the Pogostick  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-September 06

EOF FUNCTION

Posted 15 April 2007 - 11:38 PM

I have a loop so i can count how many lines there are in a function, but for some reason it doesnt work and I don't understand why. IF one of you could have a look at it, it would be greatly appreciated thanks!

	 Private Function LoadScores()
		Dim Counter As Integer

		Counter = 0
		FileOpen(1, Windows.Forms.Application.StartupPath & "\HighScores.txt", OpenMode.Input)
		While Not EOF(1)
			Counter = Counter + 1
		End While
		Counter = Counter / 2
		FileClose(1)
		Return Counter
	End Function




Is This A Good Question/Topic? 0
  • +

Replies To: EOF FUNCTION

#2 Mr Mooju the Pogostick  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-September 06

Re: EOF FUNCTION

Posted 17 April 2007 - 06:15 PM

this function is important to me, and i really can't get it right. please. any help would be apprecaited
Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: EOF FUNCTION

Posted 17 April 2007 - 09:37 PM

Can you describe what specifically is not working?
Was This Post Helpful? 0
  • +
  • -

#4 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: EOF FUNCTION

Posted 17 April 2007 - 10:16 PM

Well 1 alternative why you could solve your problem, would be to count the enter keys.

Note that as notepad has line width of 1023 char's, but I am unaware if your program should have that limit.

Note if you use files, you should be certain that no errors acures and if thay did you need to handle them. I'm adwise to look here

dim count as integer = 1
dim mydata as string = GetFileContents("C:\test.txt", sErr)

For each letter as char in mydata
   if letter=char(13) then count+=1
next each



:lol: And look up again what split() function does. Beacuse you probaly might need to use it.
Was This Post Helpful? 0
  • +
  • -

#5 Mr Mooju the Pogostick  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-September 06

Re: EOF FUNCTION

Posted 18 April 2007 - 02:50 AM

ahh i see i see, thanks. well basically the thing that isnt working is the fact that when i run it, it seems to loop at an infinite amount of time. and i dont know how to fix that =S
Was This Post Helpful? 0
  • +
  • -

#6 2much2young  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 16-November 06

Re: EOF FUNCTION

Posted 19 April 2007 - 07:33 AM

View PostMr Mooju the Pogostick, on 18 Apr, 2007 - 02:50 AM, said:

ahh i see i see, thanks. well basically the thing that isnt working is the fact that when i run it, it seems to loop at an infinite amount of time. and i dont know how to fix that =S


thats because you are not actually reading the file. you probably want something like.

   
dim stLine as string
While Not EOF(1)
	  Line Input #1, stline
	  Counter = Counter + 1
   Wend


Was This Post Helpful? 0
  • +
  • -

#7 Mr Mooju the Pogostick  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 13-September 06

Re: EOF FUNCTION

Posted 19 April 2007 - 06:38 PM

omg.. i see. i just tried that out and it worked. thanks man! i appreciate it, i can't believe i didnt realise that. ive been looking at the code for yonks not picking that up its real werid. xD but thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1