Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27512

Please Help, Mathmatic Problem

$
0
0
Hi Guys, I have this code:

Code:

Sub Btn_Cntrl(sender As Object, e As EventArgs) Handles Button2.Click, Button3.Click, Button4.Click
        Dim Btn As Button = DirectCast(sender, Button)

        Select Case Btn.Name

            Case Is = "Button2"
                Income = 0
                ListBox1.Items.Add(InputBox("Enter Income Amount:" & vbCrLf & "Example: 24.99", "Income amount", "0.00"))
                For I = 0 To ListBox1.Items.Count - 1
                    Income = CDec(Income + CDbl(ListBox1.Items(I).ToString))
                Next
            Case Is = "Button3"
                Budget = 0
                ListBox2.Items.Add(InputBox("Enter Budget Amount:" & vbCrLf & "Example: 24.99", "Budget amount", "0.00"))
                For I = 0 To ListBox2.Items.Count - 1
                    Budget = CDec(Income + CDbl(ListBox2.Items(I).ToString))
                Next
            Case Is = "Button4"
                Expense = 0
                ListBox3.Items.Add(InputBox("Enter Expense Amount:" & vbCrLf & "Example: 24.99", "Expense amount", "0.00"))
                For I = 0 To ListBox3.Items.Count - 1
                    Expense = CDec(Income + CDbl(ListBox3.Items(I).ToString))
                Next

        End Select

    End Sub

And this bit too

Code:

Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
        If Me.Height = 20 Then
            Setup_Listboxes()
            Setup_Buttons()
            Me.Size = New Size(Me.Width, (Label2.Height + ListBox1.Height + Button2.Height))
        Else
            Me.Height = 20
            EndBal = (StartBal + Income) - (Budget + Expense)
            MsgBox(StartBal & " - " & Income & " - " & Budget & " - " & Expense & " - " & EndBal)
            MsgBox(StartBal + Income)
            MsgBox(Budget + Expense)
            Label5.Text = CStr(EndBal)
        End If
    End Sub

They should be producing an Endbal for me. but this is the result i get when i enter Startbal: 100.00 income: 10.00 Budget: 5.00 Expense: 2.50:

82.50

it should be 102.50

I have seperated out the individual results in the msgboxes and found them to be like this:

Startbal: 100.00, Income: 10.00 Budget: 15.00 Expense: 12.50

It seems to be adding a 1 in front of my budget and expense

Please help... i know this is probably something very simple and i havn't looked properly... but it is pissing me off lol

Viewing all articles
Browse latest Browse all 27512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>