Solved

VB Load time display

Posted on 2001-07-31
25
152 Views
Last Modified: 2006-11-17
I've designed screen with a progress bar while the system loads data to my recordset through ODBC.  How would I incorporate a timer display which will diplay in seconds how long the process takes, start timer will be at loading the form and ending once this finishes loading. I need to display the timer in the foreground while other forms load in the background (frm2.hide).  this will provide a user with feedback in how long the forms take to load.

Thank you for your expert help !

ogueds
0
Comment
Question by:Ogueds
  • 9
  • 8
  • 4
  • +1
25 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
Comment Utility
Save this code in a new text file with .frm extension and give a shot.

VERSION 5.00
Begin VB.Form frmCronos
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   555
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   1920
   Icon            =   "frmCronos.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   555
   ScaleWidth      =   1920
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer Timer1
      Interval        =   1000
      Left            =   1860
      Top             =   1800
   End
   Begin VB.Label Label1
      Alignment       =   2  'Center
      BackColor       =   &H00FFFFFF&
      BorderStyle     =   1  'Fixed Single
      Caption         =   "00:00:00"
      BeginProperty Font
         Name            =   "Courier New"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   435
      Left            =   60
      TabIndex        =   0
      Top             =   60
      Width           =   1815
   End
End
Attribute VB_Name = "frmCronos"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Click()
Unload Me
End Sub

Private Sub Timer1_Timer()
Static H As Integer, M As Integer, S As Integer
If S = 59 Then
    S = 0
    If M = 59 Then
        M = 0
        If H = 24 Then
            H = 0
        Else
            H = H + 1
        End If
    Else
        M = M + 1
    End If
Else
    S = S + 1
End If
Label1.Caption = Format$(H, "00") & ":" & Format$(M, "00") & ":" & Format$(S, "00")
End Sub


0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
Haven't tried it, but it looks like a change needs to be made. Ignore me if I'm wrong:

If S = 59 Then
   S = 0
   If M = 59 Then
       M = 0
       If H = 24 Then

Should be:

If S = 59 Then
   S = 0
   M = M + 1
   If M = 59 Then
       M = 0
       H = H + 1
       If H = 24 Then
0
 
LVL 1

Expert Comment

by:fparie
Comment Utility
almost....

S = S + 1
If S = 60 Then
  S = 0
  M = M + 1
  If M = 60 Then
      M = 0
      H = H + 1
      If H = 25 Then
           H = 0

But let's just hope your process doesn't take that long :)

francois
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
Rats! Got a chance to show off and screwed it up! <grin>

If he needs more than just the seconds, I hope I never accidently run that procedure!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
fpaire, KDivad, i didn't understand you, guys!
I tried that code to almost 15 minutes without any problem.
(I didn't test it to an hour or 24 hours either)
0
 
LVL 1

Expert Comment

by:fparie
Comment Utility
did you check carefully richie?

i'm sure it will skip from 58s to 0s, 58m to 0m.

francois
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
It displays 59, then, next second it displays 1:00.
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
Oops, he's right. Didn't look close enough. ^*$&@# font makes reading code dificult...
0
 

Author Comment

by:Ogueds
Comment Utility
I'm still having problems displaying the timer form in the foreground while. other forms load in the background.  help how do I do this ?

Thank you
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Sorry, i think i don't deserve a B grade so i will not post any other comment.
Cheers
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
You should never give less than an A unless you have asked the expert for more help and they didn't do so. In this case, you just accepted with a low grade instead of requesting help with the additional problem first. I agree completely with Richie's choice.
0
 

Author Comment

by:Ogueds
Comment Utility
I sound like you guys are on an ego trip.  Are u guys trying to help other users or just worry about ratings.
Excuse me I'm new in this forum.

Thank you.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Sometimes, i post only clues or guesses without take care if i got points or not, just for the sake of help another guy.
This time, the code posted works 100% so this is nothing to do with ego or something like that.
I am the first person to accept if my post is awfull, middle-solution, just right or complete functional.
You could see my profile and if you encounter other threads were i was participating, you will see with your own eyes.
Cheers.
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
I'm not here for the points either.

You accepted the answer as it stands. Richie has gotten a lower grade than he would have gotten if you had asked for more help before accepting. Now, even if he fixes your problem, he can't get his rating back to where it could have been.

It's not so much that we worry about the rating, it's just the principle of the matter. When you post here, you agree to follow the guidelines for the way things are done. In this case (and in almost every other one I've read), it doesn't appear that you've read those guidelines. If I had the link, I'd post it word for word, but it basically says what I put in my previous post. Ask for more help and then give a lower grade only if more help doesn't occur.

(Maybe they should give tests on the quidelines as part of signing up to make sure people read them!)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
KDivad, i agree with you and we have been crossing each other in other task and you don't let me cheat with i am talking.
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
Eh? I don't let you cheat? I don't recall when you've tried...

I noticed that I had been seeing your name here alot!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
I mean, you know me from others tasks and you know that my thinking is almost clear on those matters.
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
Ah, ok. Yeah, you're right. From what I can gather of you from this board, you seem to be level-headed and fair. A rare combo in these days of almost-anonymity...
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
That's why I had no trouble adding my support.
0
 
LVL 1

Expert Comment

by:fparie
Comment Utility
interesting...

back to the heart of the matter... Ogueds, you still need help on getting that form to the foreground? if so, i will need to know how you load and display your forms.

sometimes, a simple DoEvents() and/or [Form].Refresh in the right place will do the trick. On other occasions, an out-of-process call is needed to have things run smoothly and independantly.

tell me what you're doing and we'll see how we can make it work.

francois
0
 

Author Comment

by:Ogueds
Comment Utility
Thank you Richie for your support.  I will be more carefull about grading in the future.  You can take advantage of the additinal points I've offered.

Ogueds
0
 

Author Comment

by:Ogueds
Comment Utility
fparie

I'm loading a form with a progressbar based on a loop, to give the user an indication that something is happening.  after the progressbar is completed then the main forms get loaded with form.hide. the main forms connect to the backend and load the recordsets (about 8k records) while this is happening in the background I would like to display a timer along with the progress bar to show how long the hidden forms take to load.hide.

thank you.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
Ogueds, thanks but the point is not about points(pun not intented;).
0
 
LVL 5

Expert Comment

by:KDivad
Comment Utility
<< I will be more carefull about grading in the future. >>

That's all we ask. Thanks for understanding our view!

KDL
0
 
LVL 1

Expert Comment

by:fparie
Comment Utility
the most simple solution would be to have the loop that is actually loading your data also update the value of the progressbar. after doing this call the refesh method of the form displaying the progressbar and after that insert a DoEvents() into your loop. make sure you use a seperate module for loading the data. that should keep your progressbar visible throughout the process. if this doesn't solve it for you i have a stronger solution but that will be a little more complicated to explain so you may want to try this first.

good luck,
francois
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now