Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,051 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,715 people online right now. Registration is fast and FREE... Join Now!




Working with negative numbers and equations: Solved

 
Reply to this topicStart new topic

Working with negative numbers and equations: Solved

gram999
5 Feb, 2008 - 11:44 AM
Post #1

D.I.C Head
**

Joined: 21 Jan, 2008
Posts: 81



Thanked: 2 times
My Contributions
I have a tool that I developed in Excel using VB that I am trying to convert to a stand alone VB.NET program and I am having some tough sledding. In the equation (code is below) it is possible to have negative numbers. I currently have a userform with 3 masked (#.#) text boxes (dPP, dPC, dPA). A user might input the following scenario:

dPP = 5.0
dPC = 8.0
dPA = 2.0

If these were the inputs in the textboxes the equation should do the following:

8.0 > 5.0
dSP = 5.0 - 8.0
dPPR = -3.0 + 2.0
dPPR = -1.0

Unfortunately, when the equation is running I am getting a 2.0 so it looks as if it will not calculate negative numbers the way I currently have it written. I have tried Dimming as Integer and as Doubles but neither seems to have an effect. Thanks in advance for taking a look at this.

CODE
Private Sub cmdbDEAddDef_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbDEAddDef.Click

        Dim strNote As String
        Dim strYNBx As String
        Dim dPP, dPC, dPA As Double
        Dim dSP As Double
        Dim dPPR As Double

        
        'Converts the Possible Point Total to Double

        dPP = CDbl(txtDEPossPoints.Text.Trim)  
        dPC = CDbl(txtDEPointCited.Text.Trim)    ‘Points Cited
        dPA = CDbl(txtDETotalPtsApp.Text.Trim)    ‘Total Points being appealed

If dPC > dPP Then  

            dSP = dPP - dPC    

            dPPR = (dSP + dPA)  
        
Else

If dPC <= dPP Then dPPR = dPA  

        End If


This post has been edited by gram999: 5 Feb, 2008 - 01:23 PM
User is offlineProfile CardPM
+Quote Post

gram999
RE: Working With Negative Numbers And Equations: Solved
5 Feb, 2008 - 01:26 PM
Post #2

D.I.C Head
**

Joined: 21 Jan, 2008
Posts: 81



Thanked: 2 times
My Contributions
Thanks for taking a look at this for me but I think I worked it out. It looks something like this:

CODE

Private Sub cmdbDEAddDef_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbDEAddDef.Click

        Dim strNote As String
        Dim strYNBx As String
        Dim iPP, iPC, iPA As Integer
        Dim iPPR As Integer

iPP = CInt(txtDEPossPoints.Text.Trim)
        iPC = CInt(txtDEPointCited.Text.Trim)
        iPA = CInt(txtDETotalPtsApp.Text.Trim)

        If iPC > iPP Then iPPR = ((iPP - iPC) + iPA)

        If iPC <= iPP Then iPPR = iPA



Thanks again for taking a look at this one.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:15PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month