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

A button not working

$
0
0
Public Class Form1

    Dim num As Double
    Dim rtlPrice As Double
    Dim whlSaleCost As Double
    Dim grsProfit As Double
    Dim strCharge As Double
    Dim netProfit As Double
    Dim quantity As Double
    Dim accQuantity As Double
    Dim accNetProfit As Double
    Dim avgNetProfit As Double

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button2.Enabled = True
        Button1.Enabled = False

        If Not Double.TryParse(TextBox3.Text, num) Then
            MessageBox.Show("Error in Retail Price, Wholesale Cost or Quantity", "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)

        ElseIf Not Double.TryParse(TextBox4.Text, num) Then
            MessageBox.Show("Error in Retail Price, Wholesale Cost or Quantity", "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)

        ElseIf Not Double.TryParse(TextBox5.Text, num) Then
            MessageBox.Show("Error in Retail Price, Wholesale Cost or Quantity", "Data Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        End If

        TextBox6.Text = (Val(TextBox3.Text) - Val(TextBox4.Text)) * Val(TextBox5.Text)
        TextBox7.Text = Val(TextBox6.Text) * 5 / 100
        TextBox8.Text = Val(TextBox6.Text) - Val(TextBox7.Text)

        accQuantity = accQuantity + quantity
        accNetProfit = accNetProfit + netProfit


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""

        TextBox1.Focus()

        Button1.Enabled = True
        Button2.Enabled = False

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If accNetProfit = 0 Or accQuantity = 0 Then
            MsgBox("No Parts estimates have been made yet", MsgBoxStyle.Information) '//Display message//
        Else
            avgNetProfit = FormatNumber((accNetProfit / accQuantity), 2)
            MsgBox("Total Net Profit : " & accNetProfit & vbNewLine & "Total Quantity : " & accQuantity & vbNewLine & " Avarage Net Profit : " & avgNetProfit) '//Display results on Message box//
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()

    End Sub

End Class



When I click the button3 else part won't work. Can somebody find me the bug???

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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