I didn't have a really close look at your code but one thing stood out:
In your sub LoadConfigFiles() try changing this line:
VB Code:
Do Until (strFinishTime = Time)
to
Do Until (strFinishTime [color=red]>=[/color] Time)
The reason I suggest that, is because the finish time may pass while that loop statement is being executed so when the test is made again, ie (strFinishTime = Time) it will never be true.
Just a thought.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
However, this is a bad way to do it.
What I would do is place all that code in a timer.
Then when you start the process, just enable the timer. Place the timer on say a 100ms interval.
This means that it won't scoff CPU time by looping constantly.
When ytou want the process to stop, just disable the time.
Does that help?
Ouch...just had another look at your code. You have a
VB Code:
Do
'shed loads of code
Loop
This puts you in an infinite loop, unless an error is raised
In fact, when an error is raised, you come out of the loop, then it sends you back into the loop with a Goto
VB is not Basic or Pascal...you don't need infinate loops.
I'd have 2 timers.
One fires every 10 seconds to see what the time is and to see if it should start doing stuff.
If it does then it enables the other timer
if the time has run out then it should disable the other timer
You are using Goto's...BAD BAD BAD...do you realise how hard it is for us to debug an app like that Almost impossible.
I am almost sure that it's hanging coz of your infinate loops.
Dim Woof As String, Moose As Long, Growl As Integer _
, Sausage As Boolean blah blah blah
Can be VERY confusing for a number of reasons. 1st you are spanning multiple lines. It makes it hard to find where varibles are declared. Also you need to use naming conventions. Woof is a bad name for a varible A developer, like me, who is looking at your project has trouble debugging as they don't know what varibles types are...
What you should do is:
VB Code:
Dim strWoof As String
Dim lngMoose As Long
Dim intGrowl As Integer
Dim blnSausage As Boolean
As you can see this is MUCH easier to read, and also you cans ee what var type it is just by it's name.
Another point. Don't use the END command.
I'd remove this from your app. Do a search on VBF for why not to use it.
Also...I think I may have found what's causing it to hang.
All over your app you are doing stuff like:
VB Code:
Open strLogDir & "\" & strAppFile For Append As #3
'blah blah
Close #3
It works...but it is prone to problems.
What you should do is:
VB Code:
Dim intFile As Integer
intFile = FreeFile
Open strLogDir & "\" & strAppFile For Append As #intFile
Thanks for the tips Woka, I've done what you've said and tidy'd up my coding. Renamed things like CSOURCE to strCSOURCE and so on.
Your coding is 110% wrong.
VB is not Basic or Pascal...you don't need infinate loops.
I'd have 2 timers.
One fires every 10 seconds to see what the time is and to see if it should start doing stuff.
If it does then it enables the other timer
if the time has run out then it should disable the other timer
You are using Goto's...BAD BAD BAD...do you realise how hard it is for us to debug an app like that Almost impossible.
I am almost sure that it's hanging coz of your infinate loops.
Post your current code that you have now.
Woka
Could you show me what you mean. I may sound thick but until someone points out I feel it will stay the same.
Place 2 timers on your form. tmrCheck and tmrDoStuff, then add the following:
VB Code:
Option Explicit
Private Sub Form_Load()
With tmrDoStuff
.Interval = 200
.Enabled = False
End With
With tmrCheck
.Interval = 1000
.Enabled = True
End With
End Sub
Private Sub tmrCheck_Timer()
Dim lngSec As Long
lngSec = Format(Time, "s")
If lngSec > 10 And lngSec < 50 Then
If Not tmrDoStuff.Enabled Then
tmrDoStuff.Enabled = True
End If
Else
If tmrDoStuff.Enabled Then
tmrDoStuff.Enabled = False
End If
End If
End Sub
Private Sub tmrDoStuff_Timer()
Me.Caption = Time
End Sub
The tmrCheck checks to see if the seconds of the current time are between 10 and 50. If so then it enables the other timer, otherwise it disables the other timer.