Subject: TryParse issues
Posted By: rpjamess1 Post Date: 12/1/2006 10:54:10 AM
I'm trying to use a TryParse to convert a text value to an integer value.  When I attempt to run a calculation, the variable that my calculation function recieves is always -1 regardless of the actual number being passed.  I've run message boxes both before the calculation and during and receive two different numbers.  The numbers before the calculation are correct.

This is an example of the calculation function:


Private Function SetTotal(ByVal pRanks As Integer, ByVal pMisc As Integer, ByVal pGroup As Integer)
    
    Dim total As Integer

    total = pRanks + pMisc + pGroup

    Return total

End Function


The sub that is using the calculation looks like this:


Private Sub txtAppraiseRanks_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAppraiseRanks.TextChanged
        
        Integer.TryParse(txtAppraiseRanks.Text, zeroRank)
        Integer.TryParse(txtAppraiseMisc.Text, zeroMisc)

        txtAppraiseTotal.Text = SetSkillTotal(zeroRank, zeroMisc, groupMod).ToString

End Sub


I've tried placing the TryParse within the function call as well with the same results.  The only variable that passes correctly is groupMod.  That one is set in another section of the program.

Any suggestion or reasoning as to why this is happening?


Go to topic 53054

Return to index page 105
Return to index page 104
Return to index page 103
Return to index page 102
Return to index page 101
Return to index page 100
Return to index page 99
Return to index page 98
Return to index page 97
Return to index page 96