Results 1 to 16 of 16

Thread: Progress Bar and Timer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    70

    Progress Bar and Timer

    I've never used a progress bar before so
    I need some help coding the below:

    - I want a progress bar on the bottom of my program to increase as time continues.
    So with a timer maybe I could do this; at 5 seconds the progress bar be about 1/4 complete, at 10 seconds, half complete, 15 seconds, 3/4 complete, 20 seconds fully complete, then have it reset but not start over. I don't want the progress to be choppy though, just a smooth line to the end.
    Help? Thanks



    JoshK
    [email protected]

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.     Timer1.Interval = 50
    5. End Sub
    6.  
    7. Private Sub Timer1_Timer()
    8.     If Me.ProgressBar1.Value = Me.ProgressBar1.Max Then
    9.         Me.ProgressBar1.Value = 0
    10.         Timer1.Enabled = False
    11.     Else
    12.         Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1
    13.     End If
    14. End Sub

    adjust the timer as needed
    -= a peet post =-

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    70
    Exactly what I was looking for
    Thanks pete!





    JoshK
    [email protected]

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    glad I could help Josh
    -= a peet post =-

  5. #5

    quick question

    what's the "option explicit" thing you used mean? i'm fairly new to vb so i don't know all the commands yet, but i've programmed in other languages before

  6. #6
    DaoK
    Guest
    Option Explicit will help you to find undeclared variable and will cause less error.

    try to run a program without declaring your variable with Option Explicit you will got an error.

    For more detail you should read MSDN help

  7. #7
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Option Explicit requires you to Dim, Public, Private, Global, etc. every varible or it'll be errored.

    Can be annoying at times... but some people like it.

  8. #8
    DaoK
    Guest
    Yes that what I said you need to declare your variable with Option Explicit

  9. #9
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    ALWAYS use Option Explicit !

    -= a peet post =-

  10. #10
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Originally posted by peet
    [B]ALWAYS use Option Explicit !
    Always use Option Explicit but never use the Progress bar control unless u are using lots of other controls from the same OCX.. u can quite easily build ur own control with minimal overhead.
    http://www.vbforums.com/showthread.p...hreadid=114422
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  11. #11
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    PS Peet Repeet.. i see that u have Auto Syntax Check on. That thing bugs the hell out of me... i much prefer just ot have colour coding instead of constant reminders.. stoopit thing
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  12. #12
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    peets new and improved vb settings :)

    ok Stuart, u'r abs. right... don't know why I never done that.... probl. because I never fail when writing code thus never got hassled byt that annoying msgbox errr...


    -= a peet post =-

  13. #13
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Mr Pinnochio, I can scratch ur nose from my balcony!!!

    Hey Peet, just on the same thing with vb settings. I remember reading about a registry setting that would ensure that any open code modules / forms etc would open up in their maximized state when u first started VB.. do you know about this? Do u use it? have it etc?
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  14. #14
    Frenzied Member Motoxpro's Avatar
    Join Date
    Sep 2001
    Location
    Spiro, OK
    Posts
    1,211
    ya that would be nice to have something like that

  15. #15
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by beachbum
    Mr Pinnochio, I can scratch ur nose from my balcony!!!

    Hey Peet, just on the same thing with vb settings. I remember reading about a registry setting that would ensure that any open code modules / forms etc would open up in their maximized state when u first started VB.. do you know about this? Do u use it? have it etc?
    uh.. no .. sorry
    -= a peet post =-

  16. #16
    DaoK
    Guest
    I hate the Ding song when I do move a part of a code an it broke a condition but I have never checker in the Option to take off the check. Thx for the tip

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