Results 1 to 15 of 15

Thread: Progress bar and timer

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Progress bar and timer

    I would like to make progress bar.. How I can show the prograss bar with the time taken to open my application. How I can start on this?

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Progress bar and timer

    Hmm I think you will find this pretty difficult. You need to use the GetTickCount API, but if you increase the progress bar by so much each time, it will appear to be stuck at the same percentage.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Progress bar and timer

    Hmm.. can we use the timer on the computer to process the application and show us the progress bar with time it take to start the application. It depend on the computer processor

  4. #4

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Progress bar and timer

    How are you opening your application? Do you mean to show a progress bar while your program loads stuff when it starts?

    Can you post some of the code you have to "load" your program? I personally wouldn't use a timer or GetTickCount but put the progressbar code in the procedures that load stuff before your program starts.

  6. #6
    Junior Member
    Join Date
    May 2007
    Posts
    23

    Re: Progress bar and timer

    i will also ask the same question as DigiRev ask you...
    post up quickly so i can post the code sample you wnt

  7. #7
    Addicted Member
    Join Date
    Feb 2006
    Posts
    185

    Re: Progress bar and timer

    Or, you need a false Progress bar to display?

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Progress bar and timer

    Quote Originally Posted by r_amin
    Or, you need a false Progress bar to display?
    For things like this, this is what I've always done.

    Sometimes it is just hard, or even impossible, to programmatically get an accurate count, so you guesstimate.

  9. #9
    Member Senacharim's Avatar
    Join Date
    Feb 2008
    Posts
    56

    Re: Progress bar and timer

    Code:
    ProgressBlit = (100 / HowManyCyclesWeAreDoing) 'do this before the loop
    i = 0
    Do
      DoEvents
      i = i + 1  'i is the loop-counter, we're checking the timer once every 10 loops. (1 loop in mine was too short to measure)
    
      'stuff
      'more stuff
      'still more stuff
    
        If (i Mod 10) = 0 Then
          If i > 0 Then Interval = ((Interval * 49) + ((Timer - lTime) / 10)) / 50
         'Interval is an approximation of how long 1 loop is taking; weighted to favor what was rather than what is. 
          If i > 0 Then Int_Mod = Int(Interval * (T_Int - i))
          ReTime (Int_Mod)
          lTime = Timer
        End If
    
      ProgressBar.Value = ProgressBar.Value + ProgressBlit
    Loop Until i = 3000000 'or whatever
    Re_Time is just a subroutine which... well, here:
    Code:
    Private Sub ReTime(Int_Mod As Long)
      LblTimer.Caption = LblTimer.Caption + " " + Str(Int_Mod) & "seconds remaining"
      LblTimer.Refresh
    End Sub
    _____________________________
    . Error Code 34: There is no error .

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Progress bar and timer

    Quote Originally Posted by jin29_neci
    i will also ask the same question as DigiRev ask you...
    post up quickly so i can post the code sample you wnt
    I no idea how to start.I don't know how to start so I would like to see the sample so that I got and idea.

    I just use the mouse down click on application exe manually like your done to open the word program . I would like to do like this While waiting the program is opened, I would like to show the prograss bar to let me know that the program I try to open is still in process.

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Progress bar and timer

    Progress bars are incremented during loops.

    Are you doing any looping when your application starts?

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Progress bar and timer

    Quote Originally Posted by Senacharim
    Code:
    ProgressBlit = (100 /
    How I can use your code?

  13. #13
    Member Senacharim's Avatar
    Join Date
    Feb 2008
    Posts
    56

    Re: Progress bar and timer

    Quote Originally Posted by matrik02
    How I can use your code?
    Code:
    ProgressBlit = (100 / HowManyCyclesWeAreDoing)
    'the progressblit sets the increment, or how far the progress bar moves for_
    each cycle.
    i = 0
    ' i  is the counter, for how many loops for progressed.
    'alternately, one could use a For i = 1 to x : Next i to do the same.
    
    Do
     i = i + 1
      ProgressBar.Value = ProgressBar.Value + ProgressBlit
    Loop Until i = 300 'or whatever
    Above is the important part, if all you want is a progress bar.

    You'll need to add a progress bar object to your form as well.
    Last edited by Senacharim; May 12th, 2008 at 01:34 PM.
    _____________________________
    . Error Code 34: There is no error .

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Progress bar and timer

    Please notice the loop that I have previously indicated needs to be present in order to effectively use the progress bar.

  15. #15
    Junior Member
    Join Date
    May 2007
    Posts
    23

    Re: Progress bar and timer

    Quote Originally Posted by matrik02
    I no idea how to start.I don't know how to start so I would like to see the sample so that I got and idea.

    I just use the mouse down click on application exe manually like your done to open the word program . I would like to do like this While waiting the program is opened, I would like to show the prograss bar to let me know that the program I try to open is still in process.
    here this is a light sample so u wont get confused
    Code:
    'the time interval is 100
    'the pb.value is the progress bar value 
    
    Private Sub Timer1_Timer()
        pb.Value = pb.Value + 1
        If (pb.Value = 2) Then
        lblWait.Caption = "Please Wait"
        ElseIf (pb.Value = 4) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 8) Then
        lblWait.Caption = "Please Wait"
        ElseIf (pb.Value = 12) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 16) Then
        lblWait.Caption = "Please Wait"
        ElseIf (pb.Value = 20) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 24) Then
        lblWait.Caption = "Please Wait"
        ElseIf (pb.Value = 28) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 32) Then
        lblWait.Caption = "Connecting"
        ElseIf (pb.Value = 36) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 40) Then
        lblWait.Caption = "Connecting"
        ElseIf (pb.Value = 44) Then
        lblWait.Caption = ""
        ElseIf (pb.Value = 48) Then
        lblWait.Caption = "Connected"
        End If
        
        If pb.Value = 50 Then
            Unload Me
            frmLogin.Show
        End If
    End Sub

    i hope this might help and wont get u confused

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width