Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

VB Load time display

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
Ogueds
Asked:
Ogueds
  • 9
  • 8
  • 4
  • +1
1 Solution
 
Richie_SimonettiCommented:
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
 
KDivadCommented:
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
 
fparieCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
KDivadCommented:
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
 
Richie_SimonettiCommented:
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
 
fparieCommented:
did you check carefully richie?

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

francois
0
 
Richie_SimonettiCommented:
It displays 59, then, next second it displays 1:00.
0
 
KDivadCommented:
Oops, he's right. Didn't look close enough. ^*$&@# font makes reading code dificult...
0
 
OguedsAuthor Commented:
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
 
Richie_SimonettiCommented:
Sorry, i think i don't deserve a B grade so i will not post any other comment.
Cheers
0
 
KDivadCommented:
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
 
OguedsAuthor Commented:
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
 
Richie_SimonettiCommented:
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
 
KDivadCommented:
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
 
Richie_SimonettiCommented:
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
 
KDivadCommented:
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
 
Richie_SimonettiCommented:
I mean, you know me from others tasks and you know that my thinking is almost clear on those matters.
0
 
KDivadCommented:
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
 
KDivadCommented:
That's why I had no trouble adding my support.
0
 
fparieCommented:
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
 
OguedsAuthor Commented:
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
 
OguedsAuthor Commented:
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
 
Richie_SimonettiCommented:
Ogueds, thanks but the point is not about points(pun not intented;).
0
 
KDivadCommented:
<< I will be more carefull about grading in the future. >>

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

KDL
0
 
fparieCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 9
  • 8
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now