Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Option Explicit On
- Public Class Form1
- Dim strfullname() As String
- Private Sub btnDefault_Click(sender As System.Object, e As System.EventArgs) Handles btnDefault.Click
- txtName.Text = "Bryan Chau"
- txtMonth.Text = "6"
- txtID.Text = "123456789"
- txtStart.Text = CStr(Today)
- optTpart.Checked = True
- optPfull.Checked = True
- chkMeal.Checked = False
- chkCare.Checked = False
- txtToddler.Text = "1"
- txtPreschooler.Text = "1"
- End Sub
- Private Function GenID() As String
- strfullname = txtName.Text.Split(" "c)
- Return (strfullname(0).Substring(0, 1) + strfullname(1).Substring(0, 1) + txtID.Text.Substring(0, 4)).ToUpper
- End Function
- Private Function GenName() As String
- strfullname = txtName.Text.Split(" "c)
- Return (strfullname(1) + ", " + strfullname(0))
- End Function
- Private Sub btnCompute_Click(sender As System.Object, e As System.EventArgs) Handles btnCompute.Click
- Dim strFormat1 As String = "{0,-35}{1,13}"
- Dim strFormat2 As String = "{0,-35}{1,13:c2}"
- Dim dtStart, dtEnd As Date
- Dim bytMonth As Byte = CByte(txtMonth.Text)
- Dim bytToddler, bytPreschooler As Byte
- Dim dblMeal, dblCare As Double
- Dim strMeal, strCare As String
- Dim dblToddlerAmt, dblPreschoolerAmt, dblTotalAmt As Double
- dtStart = CDate(txtStart.Text)
- dtEnd = DateAdd(DateInterval.Month, bytMonth, dtStart)
- bytToddler = CByte(txtToddler.Text)
- bytPreschooler = CByte(txtPreschooler.Text)
- If chkMeal.Checked = True Then
- dblMeal = 150 * bytMonth * bytToddler + 200 * bytMonth * bytPreschooler
- strMeal = "Meal plan Required"
- Else
- dblMeal = 0
- strMeal = "Meal plan not needed"
- End If
- If chkCare.Checked = True Then
- dblCare = 100 * bytMonth * (bytToddler + bytPreschooler)
- strCare = "After school care required"
- Else
- dblCare = 0
- strCare = "After school care not needed"
- End If
- If optTFull.Checked = True Then
- dblToddlerAmt = 300 * bytToddler * bytMonth
- Else
- dblToddlerAmt = 200 * bytToddler * bytMonth
- End If
- If optPfull.Checked = True Then
- dblPreschoolerAmt = 450 * bytPreschooler * bytMonth
- Else
- dblPreschoolerAmt = 400 * bytPreschooler * bytMonth
- End If
- dblTotalAmt = dblPreschoolerAmt + dblToddlerAmt + dblCare + dblMeal
- lstInvoice.Items.Clear()
- lstInvoice.Items.Add(String.Format(strFormat1, "Invoice ID ", GenID))
- lstInvoice.Items.Add(String.Format(strFormat1, "Parent Name", GenName))
- lstInvoice.Items.Add(String.Format(strFormat1, "Start Date ", FormatDateTime(dtStart, DateFormat.ShortDate)))
- lstInvoice.Items.Add(String.Format(strFormat1, "End Date ", FormatDateTime(dtEnd, DateFormat.ShortDate)))
- lstInvoice.Items.Add(String.Format(strFormat1, "Number of Toddlers", txtToddler.Text))
- lstInvoice.Items.Add(String.Format(strFormat1, "Number of Preschoolers", txtPreschooler.Text))
- lstInvoice.Items.Add(String.Format(strFormat2, strMeal, dblMeal))
- lstInvoice.Items.Add(String.Format(strFormat2, strCare, dblCare))
- lstInvoice.Items.Add(String.Format(strFormat2, "Toddler amt", dblToddlerAmt))
- lstInvoice.Items.Add(String.Format(strFormat2, "Preschooler amt", dblPreschoolerAmt))
- lstInvoice.Items.Add(" ")
- lstInvoice.Items.Add(String.Format(strFormat2, "Total amt", dblTotalAmt))
- End Sub
- End Class
Add Comment
Please, Sign In to add comment