|
-
What am I doing wrong with freefile
Hi,
What's wrong with my code - which is designed to count the number of lines in long ascii files and gives the user a chance to abort the process:
HTML Code:
int_current_file_number = FreeFile
cmdCount.Visible = False
cmdStop.Visible = True
Open lstrFileName$ For Input As int_current_file_number
Do While EOF(int_current_file_number) = False
Line Input #int_current_file_number, str_input ' input file in str_input to count lines
lngNumberLines = lngNumberLines + 1 ' increment lines
If lngNumberLines Mod 1000 = 0 Then ' return focus to system every 1000 lines, update count
DoEvents
lblLines = "(total: " & lngNumberLines & ")"
End If
If blnAbort = True Then ' if user clicked stop then clear count and show count command button
lblLines.Caption = "(total: Unknown)"
cmdCount.Visible = True
cmdStop.Visible = False
Exit Do
End If
Loop
Close int_current_file_number
If I click the 'cmdstop' button somehow the int_current_file_number is incremented by one and the do...loop continues and produces a 'bad file number error'. The sub isnt revisiting the first line of code again (I used breakpoints) so how is it incrementing....??
No doubt it is some simple oversight but I just can't figure it out. Thanks for your time.
Cheers,
Vbnewbie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks