Results 1 to 13 of 13

Thread: [RESOLVED] How To Make The Progress Bar A Shot-Power Bar?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Location
    Philippines
    Posts
    24

    Resolved [RESOLVED] How To Make The Progress Bar A Shot-Power Bar?

    I'd like to know how to make the Progress Bar a shot-power gauge/bar.
    In example, if the Minimum = 0, and Maximum = 100,

    when the Progress Bar's value comes to 100, it will decrease again to 0,
    the progress bar will stop when a button is clicked.

    i have a code like this, but the powerbar's value stops at 90 or something,

    Power_Tick //ProgressBar's Name

    PowerBar.Step = 5
    PowerBar.Value += 5
    If PowerBar.Value >= PowerBar.Maximum Then
    PowerBar.Value -= 5
    ElseIf PowerBar.Value <= PowerBar.Minimum Then
    PowerBar.Value += 5
    End If

  2. #2
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: How To Make The Progress Bar A Shot-Power Bar?

    You need to set a boolean to indicate the direction. Your code will reach the maximum, then reduce the value by 5, then increase it again because it no longer satisfies the test >= .Maximum

    In Power_Tick (I assume this is the timer's tick event.)
    Static CountIncrease as Boolean = True

    Then change the code you have to set CountIncrease to False when it reaches the maximum and set it to True when it reaches the Minimum.
    Then use an If - Then checking CountIncrease and adding or subtracting as appropriate.

  3. #3
    New Member Shakir.Ahmed's Avatar
    Join Date
    Mar 2013
    Location
    Dhaka, Bangladesh
    Posts
    9

    Re: How To Make The Progress Bar A Shot-Power Bar?

    First you need to set a boolean outside the tick event. Say the boolean is m. I also assume your progress bar's name is PowerBar.
    Then timer tick event should contain this code to work like you want.

    If PowerBar.Value = 100 Then m = False
    If PowerBar.Value = 0 Then m = True

    If m Then
    PowerBar.Value += 1
    Else
    PowerBar.Value -= 1
    End If

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: How To Make The Progress Bar A Shot-Power Bar?

    You also need to get rid of the 2 lines above your if statement

  5. #5
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Quote Originally Posted by Shakir.Ahmed View Post
    First you need to set a boolean outside the tick event.
    It can be inside the tick event if it is declared as Static as I suggested.

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: How To Make The Progress Bar A Shot-Power Bar?

    There is a lag in the ProgressBar. The value may be 100, but it is showing something less.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Quote Originally Posted by dbasnett View Post
    There is a lag in the ProgressBar. The value may be 100, but it is showing something less.
    The Prograss bar itself has no lag, the lag effect happens when "Animate controls" is enabled in windows (Visual Effects settings) which is enabled by default, Disable that setting and the progress bar control visually updates as expected.
    Personally I hate all that extra animation crap and disable them.

  8. #8
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Create your own! At the end of the day it's a line moving up and down on a drawing surface. There are so many ways to do it even for the artistically unimaginative!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  9. #9
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Quote Originally Posted by dunfiddlin View Post
    Create your own! At the end of the day it's a line moving up and down on a drawing surface. There are so many ways to do it even for the artistically unimaginative!
    IOW if there is a way to tell a control not to use Windows control animations? I just can't see every commercial app having to re-invent the wheel and draw their own progress bars!

  10. #10
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: How To Make The Progress Bar A Shot-Power Bar?

    I think the assumption was that it was such an easy thing to do that there really wasn't much point in adding the control at all if it didn't make use of the fancy animation so, no. You can of course always use a scrollbar or a track bar as though it were a progress bar at a pinch. But truth is that progress bars are almost always far less necessary than anyone imagines and half the time are no more accurate as to actual progress than guessing! I can certainly think of better things to do with my eyes than lock them onto a progress bar!
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  11. #11
    New Member Shakir.Ahmed's Avatar
    Join Date
    Mar 2013
    Location
    Dhaka, Bangladesh
    Posts
    9

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Quote Originally Posted by Españolita View Post
    It can be inside the tick event if it is declared as Static as I suggested.
    Yeah. I also think so. There are many ways to do it right.

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Location
    Philippines
    Posts
    24

    Re: How To Make The Progress Bar A Shot-Power Bar?

    where will I find that menu, on how to turn off the Animate Controls?

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Feb 2013
    Location
    Philippines
    Posts
    24

    Re: How To Make The Progress Bar A Shot-Power Bar?

    Thank You To Everyone Who Posted! The Progress Bar's Value Is Now Increasing And Decreasing. I some of you know how to get the point of intersection of two power pack lines, kindly browse my other thread. I really need help on my program.

Tags for this Thread

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