Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

For..Next Nested Loop

$
0
0
I know that assigning x = store1Payroll is just setting it to 0.

I'm trying to determine how I can use the store value to modify which label the amount goes into.

Pretty stuck right now and would appreciate a point in the right direction

Thanks sn0w

Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
        'displays the stores and company payroll

        Dim inputPayroll As String
        Dim store1Payroll As Double
        Dim store2Payroll As Double
        Dim store3Payroll As Double
        Dim x As Double
        Dim storeAccumulator As Double
        Dim companyAccumulator As Double

        ' clear the storeLabels and companyLabel
        store1Label.Text = String.Empty
        store2Label.Text = String.Empty
        store3Label.Text = String.Empty
        companyLabel.Text = String.Empty

        For stores As Integer = 1 To 3

            If stores = 1 Then
                x = store1Payroll
            ElseIf stores = 2 Then
                x = store2Payroll
            ElseIf stores = 3 Then
                x = store3Payroll
            End If

            For amounts As Integer = 1 To 5

                inputPayroll = InputBox("Amounts for payroll " &
                                        amounts.ToString, "Store " &
                                        stores.ToString)
                Double.TryParse(inputPayroll, x)

                ' add amount to store sales
                storeAccumulator += x

            Next amounts

            ' add store sales to company sales
            companyAccumulator += storeAccumulator
            ' display store payrolls
            store1Label.Text = store1Payroll.ToString("N2")
            store2Label.Text = store2Payroll.ToString("N2")
            store3Label.Text = store3Payroll.ToString("N2")


        Next stores

        ' display company sales
        companyLabel.Text = "Company sales: " &
            companyAccumulator.ToString("C2")

    End Sub


Viewing all articles
Browse latest Browse all 51036

Trending Articles