• 0

Calculation Problem


Question

I try to play 

to select different checbox n then press the textbox quantity - for example i try to type 15 in the textbox quality but then the stock and total textbox turn zero. 

Plus I'm beginner, I want to know what's wrong or something missing in this coding n let me know, i want to finish my homework as soon as possible before sunday.

how to select combobox delivery to add in total label?


        'step 1 : variable Declaration

        Dim Quantity As Single
        Dim Stock As Single
        Dim Qty2 As Single
        Dim Stock2 As Single
        Dim qty3 As Single
        Dim Stock3 As Single
        Dim Qty4 As Single
        Dim stock4 As Single
        'Dim Total As single


        'Step 2 : Variable Expression

        Try

            Quantity = txtQty_Rose.Text
            Stock = lblStock_Rose.Text
            Qty2 = CType(txtQty_Lily.Text, Integer)
            Stock2 = lblStock_Lily.Text
            qty3 = CType(txtQty_Sunflower.Text, Integer)
            Stock3 = lblStock_Sunflower.Text
            Qty4 = CType(txtQty_Morning_Glory.Text, Integer)
            stock4 = lblStock_Key.Text
            'Total = lblTotal.Text

        Catch ex As Exception


            'step 3: output
            If chkRose.Checked = True Then
                lblStock_Rose.Text = Stock - Quantity
                txtTotal_Rose.Text = Quantity * 10
            End If
            If chkLily.Checked = True Then
                lblStock_Lily.Text = Stock2 - Qty2
                txtTotal_Lily.Text = Qty2 * 20
            End If
            If chkSunflower.Checked = True Then
                lblStock_Sunflower.Text = Stock3 - qty3
                txtTotal_Sunflower.Text = qty3 * 12
            End If
            If chkMorning_Glory.Checked = True Then
                lblStock_Key.Text = stock4 - Qty4
                txtTotal_Glory.Text = Qty4 * 20
            End If


        End Try

        lblTotal.Text = "Total :" & ("£") & txtTotal_Rose.Text + txtTotal_Lily.Text + txtTotal_Sunflower.Text + txtTotal_Glory.Textimage.thumb.png.af32d8fbdfe53b1ccdea79e6697234b3.png


 

Edited by Kaylee lee
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.