Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Option Explicit On
- Public Class Form2
- Dim strfullname() As String
- Private Sub btnDefault_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDefault.Click
- txtName.Text = "Bryan Chau"
- txtID.Text = "123456"
- txtAdult.Text = "2"
- txtKid.Text = "1"
- txtStartDate.Text = CStr(Today)
- optOutside.Checked = True
- opt7.Checked = True
- chkVIP.Checked = False
- chkRestaurant.Checked = False
- chkExcursion.Checked = True
- 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, 3)
- End Function
- Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
- Dim strFormat1 As String = "{0,-35}{1,13}"
- Dim strFormat2 As String = "{0,-35}{1,13:c}"
- Dim dtStart As Date = CDate(txtStartDate.Text)
- Dim dtEnd As Date
- Dim bytDay, bytAdult, bytKid As Byte
- Dim dblCharge, dblCategory, dblPackage, dblV, dblE, dblR, dblAmt As Double
- Dim strPackage As String
- bytAdult = CByte(txtAdult.Text)
- bytKid = CByte(txtKid.Text)
- If opt7.Checked = True Then
- bytDay = 7
- dblCharge = 700
- dblV = 100
- dblR = 70
- dblE = 200
- Else
- bytDay = 10
- dblCharge = 900
- dblV = 150
- dblR = 100
- dblE = 300
- End If
- dtEnd = DateAdd(DateInterval.Day, bytDay, dtStart)
- If optInside.Checked = True Then
- dblCategory = 0
- End If
- If optOutside.Checked = True Then
- dblCategory = 20 * bytAdult * bytDay + 5 * bytKid * bytDay
- End If
- If optBalcony.Checked = True Then
- dblCategory = 35 * bytAdult * bytDay + 10 * bytKid * bytDay
- End If
- If optDeluxe.Checked = True Then
- dblCategory = 50 * bytAdult * bytDay + 20 * bytAdult * bytDay
- End If
- If chkVIP.Checked = True Then
- dblPackage = dblV
- strPackage = "V"
- End If
- If chkRestaurant.Checked = True Then
- dblPackage = dblPackage + dblR
- strPackage = strPackage + "R"
- End If
- If chkExcursion.Checked = True Then
- dblPackage = dblPackage + dblE
- strPackage = strPackage + "E"
- End If
- dblAmt = dblPackage + dblCategory + dblCharge
- lstInvoice.Items.Clear()
- lstInvoice.Items.Add(String.Format(strFormat1, "Printed on", txtStartDate.Text))
- lstInvoice.Items.Add(String.Format(strFormat1, "Invoice ID", GenID))
- lstInvoice.Items.Add(String.Format(strFormat1, "Cruise Starts on", txtStartDate.Text))
- lstInvoice.Items.Add(String.Format(strFormat1, "Cruise ends on", dtEnd.ToShortDateString))
- lstInvoice.Items.Add(String.Format(strFormat1, "Number of Adults", txtAdult.Text))
- lstInvoice.Items.Add(String.Format(strFormat1, "Number of Kids", txtKid.Text))
- lstInvoice.Items.Add(String.Format(strFormat2, "Cruise basic charge", dblCharge))
- lstInvoice.Items.Add(String.Format(strFormat2, "Cruise category charge", dblCategory))
- lstInvoice.Items.Add(String.Format(strFormat2, "Cruise package charge", dblPackage))
- lstInvoice.Items.Add(String.Format(strFormat1, "Packages", strPackage))
- lstInvoice.Items.Add(" ")
- lstInvoice.Items.Add(String.Format(strFormat2, "Total Charges", dblAmt))
- End Sub
- Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- End Class
Add Comment
Please, Sign In to add comment