Option Explicit On
Option Strict On
Public Class Form1
Dim Emp As New Employee
Private Sub btnCal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCal.Click
With Emp
Try
.Id = CInt(txtId.Text)
.Name = txtName.Text
.Salary = CDbl(txtSalary.Text)
txtDisplay.Text = .Id.ToString & " " & .Name.ToString &
vbCrLf & vbCrLf & "หักภาษีเป็นจำนวนเงิน " & .TaxPaid.ToString("#,##0.00") &
" บาท" & vbCrLf & vbCrLf & "เงินเดือนสุทธิ " & .SalaryAfterTax.ToString("#,##0.00") & " บาท"
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End With
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
txtDisplay.Text = ""
txtId.Text = ""
txtName.Text = ""
txtSalary.Text = ""
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Code (VB.NET)
Option Explicit On
Option Strict On
Public Class Form1
Dim max As New FindMax
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtNum1.Text = ""
txtNum2.Text = ""
txtNum3.Text = ""
txtMax.Text = ""
End Sub
Private Sub btnFindMax_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFindMax.Click
Try
If txtNum1.Text = "" And txtNum2.Text = "" Then
If CInt(txtNum1.Text = ".") = 0 And CInt(txtNum2.Text = ".") = 0 Then
txtMax.Text = max.FindMax(CInt(txtNum3.Text)).ToString
Else
txtMax.Text = max.FindMax(CDbl(txtNum3.Text)).ToString
End If
ElseIf txtNum2.Text = "" And txtNum3.Text = "" Then
txtMax.Text = max.FindMax(CDbl(txtNum1.Text)).ToString
ElseIf txtNum1.Text = "" And txtNum3.Text = "" Then
txtMax.Text = max.FindMax(CDbl(txtNum2.Text)).ToString
ElseIf txtNum1.Text = "" Then
txtMax.Text = max.FindMax(CDbl(txtNum2.Text), CDbl(txtNum3.Text)).ToString
ElseIf txtNum2.Text = "" Then
txtMax.Text = max.FindMax(CDbl(txtNum1.Text), CDbl(txtNum3.Text)).ToString
ElseIf txtNum3.Text = "" Then
txtMax.Text = max.FindMax(CDbl(txtNum1.Text), CDbl(txtNum2.Text)).ToString
Else
txtMax.Text = max.FindMax(CDbl(txtNum1.Text), CDbl(txtNum2.Text), CDbl(txtNum3.Text)).ToString
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Code (VB.NET)
Public Class Form1
Dim myVat As New VAT
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtAmount.Text = ""
txtPrice.Text = ""
txtTotal.Text = ""
txtVat.Text = ""
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Try
If txtVat.Text = "" Then
txtTotal.Text = myVat.Add(CDbl(txtPrice.Text), CInt(txtAmount.Text)).ToString("#,##0.00")
Else
txtTotal.Text = myVat.Add(CDbl(txtVat.Text), CDbl(txtPrice.Text), CInt(txtAmount.Text)).ToString("#,##0.00")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
End Class