Skip to main content

Invoice in VB.NET

Create an Invoice application in which user enters the customer name, description, unit price and quantity for the item ordered, then clicks the add item button. The application calculates the order total by multiplying the unit price by the quantity. And calculates a discount based on the order total. The user can then add another item to the order by using all information.
Form1.vb
Public Class Form1
    Private amt As Double = 0
    Private Sub CalculateTotal(sender As Object, e As EventArgs) Handles TextBox3.TextChanged, TextBox4.TextChanged
        TextBox5.Text = Val(TextBox3.Text) * Val(TextBox4.Text)
    End Sub
    Private Sub OnClickAddItemButton(sender As Object, e As EventArgs) Handles AddItem.Click
            GroupBox1.Enabled = True
            CustName.Text = TextBox1.Text
        desclabel.Text += TextBox3.Text & vbTab & TextBox2.Text & "(" & TextBox4.Text & ")" & vbNewLine
            amt += Val(TextBox5.Text)
            totallabel.Text = amt
            discountFunction()
            TextBox1.Enabled = False
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
    End Sub
    Private Sub discountFunction()
        If amt > 2000 And amt <= 5000 Then
            Discountlabel.Text = "-" & amt * 5 / 1000
        ElseIf amt > 5000 And amt <= 20000 Then
            Discountlabel.Text = "-" & amt * 10 / 100
        ElseIf amt > 20000 Then
            Discountlabel.Text = "-" & amt * 15 / 100
        Else
            Discountlabel.Text = 0
        End If
        Amountlabel.Text = amt - Val(Discountlabel.Text)
    End Sub
End Class
DESIGNING




Comments