Hit Percent

Discussion in 'Programming General' started by tomanderson12, Mar 16, 2009.

Hit Percent
  1. Unread #1 - Mar 16, 2009 at 3:36 PM
  2. tomanderson12
    Joined:
    Jan 21, 2008
    Posts:
    53
    Referrals:
    0
    Sythe Gold:
    0

    tomanderson12 Member

    Hit Percent

    Im currently making a game in which you have to hit an image, you hit it the score goes up by one. Im trying to add a percentage hit, so I have two hidden labels one counting the forms click the other for the image. I have a label called lblpercent2. I thought it would just be

    Code:
    lblpercent2.caption = Val(text1.text) / Val(text2.text)
    But that doesn't work
     
  3. Unread #2 - Mar 16, 2009 at 4:37 PM
  4. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Hit Percent

    If you PM me the source I may be able to help... but that post made no sense. :(
     
  5. Unread #3 - Mar 18, 2009 at 10:42 PM
  6. tomanderson12
    Joined:
    Jan 21, 2008
    Posts:
    53
    Referrals:
    0
    Sythe Gold:
    0

    tomanderson12 Member

    Hit Percent

    I PM'd the source to you
     
  7. Unread #4 - Mar 19, 2009 at 6:13 AM
  8. Darthatron
    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Hit Percent

    Ok, so the problem was that you weren't finding the percentage correctly. It should be:
    Code:
    Percentage = Hits / (Hits + Misses) * 100
    you had...
    Code:
    Percentage = Hits / Misses
    So the code should be:
    Code:
    lblpercent2.Caption = Val(Text1.Text) / (Val(Text2.Text) + Val(Text1.Text)) * 100
    -
    Also, learn to use variables and correctly name your objects. >_>
     
< Help me? | More Help needed by Esuom... >

Users viewing this thread
1 guest


 
 
Adblock breaks this site