Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8977791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:27:13+00:00 2026-06-15T19:27:13+00:00

I’m trying to simulate a game whereby a player can damage an enemy or

  • 0

I’m trying to simulate a game whereby a player can damage an enemy or heal themselves via clicking buttons “Attack” and “Heal”. I’ve tried to do a test-run on one Progress Bar to just make sure everything works before modifying it to fit my game, and made a new WindowsApplication.

I have a Progress Bar on the form along with one Attack button and a Heal button and if I exceed the maximum value of the progress bar by healing or minimum by damaging, it spews out errors. I can’t figure out the line of code in which to fix it for both cases and I’ve been looking everywhere for answers.

Here’s my Heal Button Code;

Private Sub btnHeal_Click(ByVal sender As System.Object, _
                          ByVal e As System.EventArgs) _
                      Handles btnHeal.Click

    prgHealth.Value = prgHealth.Value + 10

    If prgHealth.Value >= prgHealth.Maximum Then
        prgHealth.Value = prgHealth.Maximum
    End If

End Sub

And here’s my Damage Button Code;

Private Sub btnDamage_Click(ByVal sender As System.Object, _
                            ByVal e As System.EventArgs) _
                        Handles btnDamage.Click

    prgHealth.Value = prgHealth.Value - 10

    If prgHealth.Value < prgHealth.Minimum Then
        prgHealth.Value = prgHealth.Minimum
    End If

End Sub

Any help would be greatly appreciated.
Please also note that I’m a beginner at coding and will definitely get confused with large walls of code.

I’m sure many people who have messed with Progress Bars like this will have had the same problem, and I know it’s probably something silly!

Thank ye for helping!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:27:14+00:00Added an answer on June 15, 2026 at 7:27 pm

    You are doing things in the wrong order.
    Your first apply the change to the progressbar, then you check if it more than maximum or less then minimum.
    Think of the progressbar as a glass of water. You cant fill it up over the edge (No smartass comments about Ice now people) because then you’ll have water everywhere. You also cannot withdraw more water than what is in the glass (No smartass comments about dehumidifying now please). What you do now is to first fill the progressbar with too much water so it goes over the edge. Then check if you poured to much water into the glass. Rather than meassuring the amount of water before pouring it into the glass. 😀

    You need to do the check first. Like this:

    if prgHealth.Value + 10 > prgHealth.Maximum Then
      prgHealth.Value = prgHealth.Maximum
    else
      prghealth.Value = prgHealth.Value + 10
    end if
    

    And then the same for minimum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.