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

Clear VB6 Memroy

Status
Not open for further replies.

Shane4DaBears

Programmer
Nov 29, 2004
10
US
Hello,
I am working on a VB application that looks for a file in a network DIR. When it finds the file, it moves it to a backup DIR and then parses the file and does some transactional work. Then it will go back and look in the DIR for another file. It works great except for then the date changes. So every might at midnight it errors looking for the file in the Timer Interval loop. I believe if I could clear the memory of the application and direct it to the startup module it would be fine.
Any help would be appreciated!
Thanks
 
No, I am not re-reading in the ini settings.
Here is the code for loading ini settings:
Private Function IniExists() As Boolean
On Error GoTo ErrorHandler

If Dir(App.Path & "\" & IniFileName, vbNormal) = "" Then
ErrorMessage = "The ini file was not present. A blank ini file has been created so that you can add the program parameters."
IniExists = False
Else
IniExists = True
End If
Exit Function

ErrorHandler:
ErrorMessage = "A Error has occured while locating the ini file."
logger.WriteError logger.PROD_LOGGING
IniExists = False
End Function

Private Function LoadSettings() As Boolean
On Error GoTo ErrorHandler
'read the values into the collection
Dim eqPos As Integer
Dim strLen As Integer
Dim fHandle As Integer
Dim CurLine As String
fHandle = FreeFile()
Open App.Path & "\" & IniFileName For Input As #fHandle
While Not EOF(fHandle)
Input #fHandle, CurLine
If Not (Left(CurLine, 1) = "[" Or CurLine = "" Or CurLine = ";") Then
strLen = Len(CurLine)
eqPos = InStr(1, CurLine, "=", vbTextCompare)
IniSettings.Add Right(CurLine, strLen - eqPos), Left(CurLine, eqPos - 1)
End If
Wend
Close (fHandle)
LoadSettings = True
Exit Function
ErrorHandler:
ErrorMessage = "A Error has occured while loading the ini file."
logger.WriteError logger.PROD_LOGGING
LoadSettings = False
End Function
Public Function GetIniValue(IniKey As String) As String
GetIniValue = IniSettings(IniKey)
End Function




I have temporarily resolved the problem and here is how?????????
IN the timer interval I have put two lines of code and it has seemed to work. Don't think this is a resolution, but let me know what you think for a permanent solution.

Do While newFile <> "" ' Start the loop.
If newFile <> "." And newFile <> ".." Then
If UCase(newFile) = PACKS_FILE_NAME Then
If FileWorker.ProcessFile(newFile) Then
logger.WriteString "File: " & FileWorker.NewFileName & " has been processed successfully", logger.PROD_LOGGING
'Next two lines of code were added to resolve the issue of the the
'application failing after midnight. RDS 12-01-04
newFile = ""
newFile = Dir(FileWorker.GetIncomingDir, vbDirectory)
Else
logger.WriteString newFile & " has not complete successfully: ", logger.PROD_LOGGING
'Next two lines of code were added to resolve the issue of the the
'application failing after midnight. RDS 12-01-04
newFile = ""
newFile = Dir(FileWorker.GetIncomingDir, vbDirectory)
End If
Else
FileWorker.ArchiveFile (newFile)
End If
End If
newFile = Dir ' Get next entry.
Loop
 
12:00:38 Error# 0 Source: Desc:
12:00:53 Error# 457 Source: LmbrGrdr Desc: This key is already associated with an element of this collection
12:00:58 A Error has occured while loading the ini file.
12:01:06 Error# 1023 Source: MainModule.Main Desc: Fail to load the Ini File
12:01:40 Error# 0 Source: Desc:
00:00:26 Error# 0 Source: Desc:
16:44:35 Error# 424 Source: LmbrGrdr Desc: Object requir
and
Code:
.
.
.
    Exit Function
ErrorHandler:
[COLOR=blue]    ErrorMessage = "A Error has occured while loading  the ini file."[/color]
    logger.WriteError logger.PROD_LOGGING
    LoadSettings = False
End Function

From the look of the loadsettings function is hitting its error handler at midnight. How do you restart sub main at midnight?



Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
On first glance:

1) Why invoke the NTService1.StartService method from within the NTService1_Start event? Would this not create multiple instances of the service?

2) In the NTService1_Start event the timer interval is being set (I assume) to a value greater than zero. (I also assume that the enabled property of the timer is set to TRUE at design time.) Therefore, if the NTService1.Start method (which is synchronous) takes longer to execute than the timer interval, then the timer event will fire (or enqueue) before the StartService event has completed.

3) strongm mentioned this ealier, because you do not set the timer enabled property to False in the timer event, if the "Do While" loop in that event takes longer to execute than the timer interval, then once again another event will be either fired or enqueued.

3) In your third post, showing the error messages, has the app been running before midnight or are those message from an app that was started immediately after midnight?

I am still looking for the midnight bit.

Cheers.

&quot;Life is full of learning, and then there is wisdom&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top