Simple Maths Problem

kurt69

Well-known member
Joined
Jan 17, 2006
Messages
78
Location
Australia
Programming Experience
Beginner
(this is long winded)
My application is a game, the user creates a character and enters in some statistics like Attack level and etc. This saves the name of the character, the characters portrait, all of his stats and his remaining stat points to spend. Now when the user loads this character he is taken to a form to modify his stats and spend any points he hasn't. I have a Public Shared variable
that determines how many stat points are available to spend: availablePoints.

Now for some reason when the user presses save it isn't calculating the remaining stat points properly. For example, the user starts with 60 points, spends 6 when creating his/her character (so theres 54 points left). He/She then goes into the form that allows her to modify her stats, changes the value of a numeric up/down control by increasing it by 1. Instead of 53 points being left it shows 47. Now if i decrease this value by 1 it shows 48 points remaining. Somehow I'm losing 8 points.

Alright I know it's on the stat modify form, not character creation form that is losing the 8 points. Here are the only real codes that change it:

(sharedVariables.availablePoints is defined as Public Shared in another class)

VB.NET:
    Dim spendablePoints As Integer
    Dim startSpendablePoints As Integer
VB.NET:
spendablePoints = sharedVariables.availablePoints
        startSpendablePoints = sharedVariables.availablePoints
VB.NET:
    Private Sub inpSpeed_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles inpSpeed.ValueChanged
        spendablePoints = startSpendablePoints - (inpAttack.Value + inpDefense.Value + inpHealth.Value + inpMana.Value + inpPower.Value + inpSpeed.Value)
        lblAvailablePoints.Text = "You have " & spendablePoints & " statistic points to spend."
    End Sub
 
Ok it says the values for my numeric up/down controls are all 1D, I am guessing this is the reason the maths isn't adding up because I can't see anything wrong with my maths.
 
Back
Top