0% found this document useful (0 votes)
24 views3 pages

Option Explicit Private Sub Cmdcrayonscompute - Click If Val (Txtstockcrayons - Text) Val (Cbocrayonsqty - Text) Then

The document contains code for calculating totals for crayons, paper, and pencils purchased. It checks stock quantities, calculates item totals by multiplying quantity and price, adds item totals to a running total, and formats totals with two decimal places. Dropdown lists for quantities are populated with numbers from 1 to 100.

Uploaded by

pangdownloadlang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Option Explicit Private Sub Cmdcrayonscompute - Click If Val (Txtstockcrayons - Text) Val (Cbocrayonsqty - Text) Then

The document contains code for calculating totals for crayons, paper, and pencils purchased. It checks stock quantities, calculates item totals by multiplying quantity and price, adds item totals to a running total, and formats totals with two decimal places. Dropdown lists for quantities are populated with numbers from 1 to 100.

Uploaded by

pangdownloadlang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Option Explicit

Private Sub cmdCrayonsCompute_Click()

If Val(txtStockCrayons.Text) < Val(cboCrayonsQty.Text) Then

MsgBox "Crayons Stocks are not enought.", vbCritical, "Crayons Stock"

Exit Sub

Else

txtStockCrayons.Text = Val(txtStockCrayons.Text) - Val(cboCrayonsQty.Text)

End If

txtCrayonsTotal.Text = Val(cboCrayonsQty.Text) * Val(txtCrayonsPrice.Text)

txtCrayonsTotal.Text = Format(txtCrayonsTotal.Text, "###.00")


txtTotalAmount.Text = Val(txtTotalAmount.Text) + Val(txtCrayonsTotal.Text)

txtTotalAmount.Text = Format(txtTotalAmount.Text, "###.00")

End Sub

Private Sub cmdPaperCompute_Click()

If Val(txtStockPaper.Text) < Val(cboPaperQty.Text) Then

MsgBox "Paper Stocks are not enought.", vbCritical, "Paper Stock"

Exit Sub

Else

txtStockPaper.Text = Val(txtStockPaper.Text) - Val(cboPaperQty.Text)

End If

txtPaperTotal.Text = Val(cboPaperQty.Text) * Val(txtPaperPrice.Text)

txtPaperTotal.Text = Format(txtPaperTotal.Text, "###.00")

txtTotalAmount.Text = Val(txtTotalAmount.Text) + Val(txtPaperTotal.Text)

txtTotalAmount.Text = Format(txtTotalAmount.Text, "###.00")

End Sub

Private Sub cmdPencilCompute_Click()

If Val(txtStockPencil.Text) < Val(cboPencilQty.Text) Then

MsgBox "Pencil Stocks are not enought.", vbCritical, "Pencil Stock"

Exit Sub

Else
txtStockPencil.Text = Val(txtStockPencil.Text) - Val(cboPencilQty.Text)

End If

txtPencilTotal.Text = Val(cboPencilQty.Text) * Val(txtPencilPrice.Text)

txtPencilTotal.Text = Format(txtPencilTotal.Text, "###.00")

txtTotalAmount.Text = Val(txtTotalAmount.Text) + Val(txtPencilTotal.Text)

txtTotalAmount.Text = Format(txtTotalAmount.Text, "###.00")

End Sub

Private Sub Form_Load()

Dim a, b, c As Integer

For a = 1 To 100

cboPencilQty.AddItem a

Next a

For b = 1 To 100

cboCrayonsQty.AddItem b

Next b

For c = 1 To 100

cboPaperQty.AddItem c

Next c

End Sub

You might also like