Option Explicit On
Option Strict On
Imports System.Drawing.Drawing2D
Public Class fromCalculator
Public Sub New(ByVal CurrentString As String)
InitializeComponent()
lblPaid.Text = CurrentString
End Sub
Private Sub fromCalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.BackColor = Color.FromArgb(0, 0, 0, 0)
Label2.BackColor = Color.FromArgb(0, 0, 0, 0)
Label3.BackColor = Color.FromArgb(0, 0, 0, 0)
Label6.BackColor = Color.FromArgb(0, 0, 0, 0)
Label4.BackColor = Color.FromArgb(0, 0, 0, 0)
Label7.BackColor = Color.FromArgb(0, 0, 0, 0)
Label5.BackColor = Color.FromArgb(0, 0, 0, 0)
Label8.BackColor = Color.FromArgb(0, 0, 0, 0)
txtCash.ContextMenu = New ContextMenu()
' txtVATRate.ContextMenu = New ContextMenu()
txtCash.Text = "0"
lblExchange.Text = "0"
' txtVATRate.Text = "7"
End Sub
Private Sub txtCash_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCash.TextChanged
'เหตุการณ์ใสจำนวนเงินที่รับมา
If lblPaid.Text.Trim() = "" Then lblPaid.Text = "0" 'จำนวนเงินที่ต้องชำระ
If txtCash.Text.Trim() = "" Then txtCash.Text = "0" 'รับเงินที่ชำระมา
If lblVate.Text.Trim() = "" Then lblVate.Text = "0" 'ภาษี
If CDbl(txtCash.Text) = 0 Then
lblExchange.Text = "0" 'เงินทอน
Exit Sub
End If
lblExchange.Text = (CDbl(txtCash.Text) - CDbl(lblPaid.Text)).ToString("#,##0.00") 'แสดงจำนวนเงินทอน
' lblVate.Text = CSng(txtCash * (CSng(txtVATRate.Text) / 100)).ToString("#,##0.00") 'แสดงภาษี
End Sub
Private Sub txtCash_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtCash.KeyPress
e.Handled = CurrencyTextBox.CurrencyOnly(txtCash, e.KeyChar)
End Sub
'Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
' Me.Close()
'End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim lgb As New LinearGradientBrush(ClientRectangle, Color.Yellow, Color.LawnGreen, LinearGradientMode.Vertical)
e.Graphics.FillRectangle(lgb, ClientRectangle)
lgb.Dispose()
End Sub
End Class