Code Comments
Programming Forum and web based access to our favorite programming groups.VB6 - I made a [help][about] form which is five time slower to load/show from the compiled EXE than in the IDE. IDE -- 1 second EXE -- 5 seconds What could be the reason that the compiled program would execute more slowly than in the IDE? Here is the code in frmabout : ====start Option Explicit Private Sub Form_Load() Static ExpireDate As Date Static FirstRunDate As String lblTitle.Caption = App.TITLE & " - Version " & App.Major & "." & App.Minor & "." & App.Revision If MDIForm1.IsLicensed Then lblUser = "Licenced to: " & MDIForm1.UserNameAndCompany _ & vbNewLine & "Serial Number:" & MDIForm1.SerialNumber Else lblUser = "Not licensed, used by: " & MDIForm1.UserNameAndCompany End If With MDIForm1 If .IsTimed Then ExpireDate = CDate(.FirstRunDate) + .TrialDaysAllowed If Date <= ExpireDate Then 'not expired. lblTimedOut = "This " & .TrialName & " was installed on " & .FirstRunDate _ & " and its " & .TrialDaysAllowed & " day trial will expire after " _ & ExpireDate - CDate(.FirstRunDate) & " days on " & ExpireDate Else 'expired. lblTimedOut = "This " & .TrialName & " expired on " & ExpireDate & ", " _ & .TrialDaysAllowed & " after its first run on " & .FirstRunDate End If Else 'is not timed. lblTimedOut = "Permanently assigned" End If End With lblDescription.Caption = _ "TP105 designs acceptance sampling plans for attributes." _ & vbNewLine & "using the two-point method to specify an oc curve and" _ & vbNewLine & "calculates its fixed-n and sequential decision rules." lblDisclaimer = "Copyright (c) 2004 H & H Servicco Corp." _ & vbNewLine & "All rights reserved." _ & vbNewLine & "www.samplingplans.com" End Sub Private Sub cmdOK_Click() Unload Me End Sub ====end Information will be appreciated. Stan Hilliard
Post Follow-up to this messageThat's a lot of code to look through. Rather than try to figure it out yourself, why don't you just log code execution in the sub and narrow it down? Declare this variable and note the time at the start of the sub Dim dStart as Double dStart = Timer Around halfway through the sub, place this line Msg dStart - Timer If there's an appriciable difference between the IDE and the compiled execution, you'll know the problem lies in the first half of the sub. Otherwise, it's in the second. You can keep narrowing it down from there. Stan Hilliard <usenetreplyMS@samplingplansNOTSPAM.com> wrote in news:la0uk0dmthdedcjhrvem69n8dh7h7nsd1i@ 4ax.com: > VB6 - I made a [help][about] form which is five time slower to > load/show from the compiled EXE than in the IDE. > > IDE -- 1 second > EXE -- 5 seconds > > What could be the reason that the compiled program would execute more > slowly than in the IDE? > > Here is the code in frmabout : > ====start > Option Explicit > > Private Sub Form_Load() > Static ExpireDate As Date > Static FirstRunDate As String > lblTitle.Caption = App.TITLE & " - Version " & App.Major & "." & > App.Minor & "." & App.Revision > > If MDIForm1.IsLicensed Then > lblUser = "Licenced to: " & MDIForm1.UserNameAndCompany _ > & vbNewLine & "Serial Number:" & MDIForm1.SerialNumber > Else > lblUser = "Not licensed, used by: " & > MDIForm1.UserNameAndCompany > End If > > With MDIForm1 > If .IsTimed Then > ExpireDate = CDate(.FirstRunDate) + .TrialDaysAllowed > If Date <= ExpireDate Then 'not expired. > lblTimedOut = "This " & .TrialName & " was installed > on " & .FirstRunDate _ > & " and its " & .TrialDaysAllowed & " day trial will > expire after " _ > & ExpireDate - CDate(.FirstRunDate) & " days on " & > ExpireDate > Else 'expired. > lblTimedOut = "This " & .TrialName & " expired on " & > ExpireDate & ", " _ > & .TrialDaysAllowed & " after its first run on " & > .FirstRunDate > End If > Else 'is not timed. > lblTimedOut = "Permanently assigned" > End If > End With > > lblDescription.Caption = _ > "TP105 designs acceptance sampling plans for attributes." _ > & vbNewLine & "using the two-point method to specify an oc > curve and" _ > & vbNewLine & "calculates its fixed-n and sequential decision > rules." > > lblDisclaimer = "Copyright (c) 2004 H & H Servicco Corp." _ > & vbNewLine & "All rights reserved." _ > & vbNewLine & "www.samplingplans.com" > > End Sub > > Private Sub cmdOK_Click() > Unload Me > End Sub > > ====end > > Information will be appreciated. > Stan Hilliard > >
Post Follow-up to this messageThe EXE and IDE versions were both fast when I added the timer code. Then I took the timer code out and they were still fast. I am puzzled because I had verified the problem 5 or 6 times, including with recompiling. Stan Hilliard On Mon, 20 Sep 2004 09:55:12 -0700, Tim Baur <trbo20@disregard_yahoo.com> wrote: >That's a lot of code to look through. Rather than try to figure it out >yourself, why don't you just log code execution in the sub and narrow it >down? > >Declare this variable and note the time at the start of the sub > >Dim dStart as Double >dStart = Timer > > >Around halfway through the sub, place this line > >Msg dStart - Timer > >If there's an appriciable difference between the IDE and the compiled >execution, you'll know the problem lies in the first half of the sub. >Otherwise, it's in the second. You can keep narrowing it down from >there. > > > > >Stan Hilliard <usenetreplyMS@samplingplansNOTSPAM.com> wrote in > news:la0uk0dmthdedcjhrvem69n8dh7h7nsd1i@ 4ax.com: >
Post Follow-up to this messageStan Hilliard <usenetreplyMS@samplingplansNOTSPAM.com> wrote in news:di9uk09hd8b43rnhfheh92tjpdrumsmqf9@ 4ax.com: > The EXE and IDE versions were both fast when I added the timer code. > > Then I took the timer code out and they were still fast. ??? Oh well, at least it's fixed.
Post Follow-up to this message"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message news:di9uk09hd8b43rnhfheh92tjpdrumsmqf9@ 4ax.com... > The EXE and IDE versions were both fast when I added the timer code. > > Then I took the timer code out and they were still fast. > > I am puzzled because I had verified the problem 5 or 6 times, > including with recompiling. Welcome to the wonderful world of programming. Sacrifice a chicken to the program in the hopes that it never does this again and move on....
Post Follow-up to this messageI found the culprit. The delayed opening of frmAbout only happens when my anti-virus program (F-Prot) is running in the background -- in "real time protector" mode. The frmAbout is so small that I don't understand why it should take 5 seconds anyway, but it does from the EXE but not from the IDE. load/show frmAbout from IDE -- 1 second Load/show the EXE -- 3 seconds load/show frmAbout from Exe -- 5 seconds Can anyone explain why the anti-virus would effect slow the EXE but not the IDE? Also, what could be the reason why would it take more time to load/show frmAbout from the EXE (5 seconds) than to load/show the whole EXE (3 seconds)? Stan Hilliard On Mon, 20 Sep 2004 11:45:25 -0500, Stan Hilliard <usenetreplyMS@samplingplansNOTSPAM.com> wrote: >VB6 - I made a [help][about] form which is five time slower to >load/show from the compiled EXE than in the IDE. > >IDE -- 1 second >EXE -- 5 seconds > >What could be the reason that the compiled program would execute more >slowly than in the IDE? > >Here is the code in frmabout : >====start >Option Explicit > >Private Sub Form_Load() > Static ExpireDate As Date > Static FirstRunDate As String > lblTitle.Caption = App.TITLE & " - Version " & App.Major & "." & >App.Minor & "." & App.Revision > > If MDIForm1.IsLicensed Then > lblUser = "Licenced to: " & MDIForm1.UserNameAndCompany _ > & vbNewLine & "Serial Number:" & MDIForm1.SerialNumber > Else > lblUser = "Not licensed, used by: " & >MDIForm1.UserNameAndCompany > End If > > With MDIForm1 > If .IsTimed Then > ExpireDate = CDate(.FirstRunDate) + .TrialDaysAllowed > If Date <= ExpireDate Then 'not expired. > lblTimedOut = "This " & .TrialName & " was installed >on " & .FirstRunDate _ > & " and its " & .TrialDaysAllowed & " day trial will >expire after " _ > & ExpireDate - CDate(.FirstRunDate) & " days on " & >ExpireDate > Else 'expired. > lblTimedOut = "This " & .TrialName & " expired on " & >ExpireDate & ", " _ > & .TrialDaysAllowed & " after its first run on " & >.FirstRunDate > End If > Else 'is not timed. > lblTimedOut = "Permanently assigned" > End If > End With > > lblDescription.Caption = _ > "TP105 designs acceptance sampling plans for attributes." _ > & vbNewLine & "using the two-point method to specify an oc >curve and" _ > & vbNewLine & "calculates its fixed-n and sequential decision >rules." > > lblDisclaimer = "Copyright (c) 2004 H & H Servicco Corp." _ > & vbNewLine & "All rights reserved." _ > & vbNewLine & "www.samplingplans.com" > >End Sub > >Private Sub cmdOK_Click() > Unload Me >End Sub > >====end > >Information will be appreciated. >Stan Hilliard
Post Follow-up to this messageStan Hilliard wrote: > Can anyone explain why the anti-virus would effect slow the EXE but > not the IDE? > > Also, what could be the reason why would it take more time to > load/show frmAbout from the EXE (5 seconds) than to load/show the > whole EXE (3 seconds)? > > Stan Hilliard Any scripting going on? FSO maybe? Registry access? -- Ken Halter - MS-MVP-VB - http://www.vbsight.com Please keep all discussions in the groups..
Post Follow-up to this messageProblems that mysteriously disappear will mysteriously reappear. You can quote me on that <vbg>. Later, Dan "Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message news:uex39q0nEHA.1712@tk2msftngp13.phx.gbl... > > "Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message > news:di9uk09hd8b43rnhfheh92tjpdrumsmqf9@ 4ax.com... > > > Welcome to the wonderful world of programming. Sacrifice a chicken to the > program in the hopes that it never does this again and move on.... > >
Post Follow-up to this messageI gotta go with Dan on this one, Jeff. That's hardly the best advice you've ever given (but I assume it was more in jest than anything else). Mike "Dan Barclay" <Dan@MVPs.org> wrote in message news:expUcYBoEHA.608@TK2MSFTNGP09.phx.gbl... > Problems that mysteriously disappear will mysteriously reappear. > > You can quote me on that <vbg>. > > Later, > Dan > > > "Jeff Johnson [MVP: VB]" <i.get@enough.spam> wrote in message > news:uex39q0nEHA.1712@tk2msftngp13.phx.gbl... message the > >
Post Follow-up to this message"Stan Hilliard" <usenetreplyMS@samplingplansNOTSPAM.com> wrote in message news:3mq0l0dn1153051gen320bhpq9oespe26f@ 4ax.com... > I found the culprit. The delayed opening of frmAbout only happens when > my anti-virus program (F-Prot) is running in the background -- in > "real time protector" mode. > > The frmAbout is so small that I don't understand why it should take 5 > seconds anyway, but it does from the EXE but not from the IDE. Well, that makes perfect sense to me. Your anti-virus software is scanning the EXE. It's not scanning anything when you run your project within the IDE (probably vb6.exe when you start VB, but that's it). 5 seconds seems excessive to me, but if your antivirus sofware is doing heuristics and whatever else, it's conceivable I suppose. It might also have to do with whatever your frmAbout module does. For example, does it utilize other files to obtain information? If so, those are probably getting checked by your antivius software as well. Mike
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.