Solved

VB Load time display

Posted on 2001-07-31
25
164 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
  • 4
  • +1
25 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 50 total points
ID: 6338611
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
ID: 6338696
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
ID: 6338724
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:KDivad
ID: 6339843
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
ID: 6340753
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
ID: 6341707
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
ID: 6342134
It displays 59, then, next second it displays 1:00.
0
 
LVL 5

Expert Comment

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

Author Comment

by:Ogueds
ID: 6348622
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
ID: 6349285
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
ID: 6350054
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
ID: 6350145
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6350321
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
ID: 6350352
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
ID: 6350572
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
ID: 6350929
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
ID: 6350947
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
ID: 6350973
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
ID: 6350976
That's why I had no trouble adding my support.
0
 
LVL 1

Expert Comment

by:fparie
ID: 6351281
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
ID: 6351318
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
ID: 6351337
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
ID: 6351699
Ogueds, thanks but the point is not about points(pun not intented;).
0
 
LVL 5

Expert Comment

by:KDivad
ID: 6352361
<< 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
ID: 6354075
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 790
Macro: print each sheet to pdf using ExportAsFixedFormat 11 62
Determine Range to Select 5 56
Problem to line 23 73
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

740 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