CURSOR lock!!!!!

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

CURSOR lock!!!!!

Post by sal21 »

Code: Select all

Private Sub Command3_Click()

Dim File As Integer
Dim TextOfLine As String
Dim Path As String

Dim sngStartTime As Single
Dim sngTotalTime As Single

sngStartTime = Timer

File = FreeFile
Open "C:\TEMP\2011.TXT" For Input As File
While Not EOF(File)
Line Input #File, TextOfLine
'...
Wend
Close File

sngTotalTime = Timer - sngStartTime
Me.Label6.Caption = Round(sngTotalTime, 2)
Me.Label5.Caption = "STOP"

End Sub

In all 90% of my project use this code with a file around 45/65 MB

Now with a file approx dimension 100 mb the cursor lock on "While Not EOF(File)" and freeze trhe macro.(no error but lock)

I need in other case to read the txt line by line

User avatar
HansV
Administrator
Posts: 78507
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CURSOR lock!!!!!

Post by HansV »

Perhaps you can split the file into two or three smaller files and process them separately?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

Re: CURSOR lock!!!!!

Post by sal21 »

HansV wrote:Perhaps you can split the file into two or three smaller files and process them separately?
i dont know tihs solution, if is s good idea :scratch:

User avatar
sal21
PlatinumLounger
Posts: 4357
Joined: 26 Apr 2010, 17:36

Re: CURSOR lock!!!!!

Post by sal21 »

HansV wrote:Perhaps you can split the file into two or three smaller files and process them separately?

Perpahs i have understand the prob.

after 13 minutes of cuesor lock, have error:

Space of string is out!!

I think the eachelines in txt not have a terminat and code consider one line teh entire txt file, possoble?

User avatar
HansV
Administrator
Posts: 78507
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: CURSOR lock!!!!!

Post by HansV »

You should be able to investigate that yourself...
Best wishes,
Hans

BenCasey
4StarLounger
Posts: 495
Joined: 13 Sep 2013, 07:56

Re: CURSOR lock!!!!!

Post by BenCasey »

The input file may be corrupt.
Try opening it in a text reader such as Notepad or similar.
Try also using FileCopy to see if both files have the same number of bytes.
Regards, Ben

"Science is the belief in the ignorance of the experts."
- Richard Feynman