Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents LblBills As System.Windows.Forms.Label Friend WithEvents LblPenie As System.Windows.Forms.Label Friend WithEvents LblNicke As System.Windows.Forms.Label Friend WithEvents LblDimes As System.Windows.Forms.Label Friend WithEvents LblQuart As System.Windows.Forms.Label Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1)) Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.LblBills = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.Label7 = New System.Windows.Forms.Label Me.Label8 = New System.Windows.Forms.Label Me.LblPenie = New System.Windows.Forms.Label Me.LblNicke = New System.Windows.Forms.Label Me.LblDimes = New System.Windows.Forms.Label Me.LblQuart = New System.Windows.Forms.Label Me.SuspendLayout() ' 'Button1 ' Me.Button1.Enabled = False Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button1.Location = New System.Drawing.Point(16, 104) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 3 Me.Button1.Text = "C&alculate" ' 'Button2 ' Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Button2.Location = New System.Drawing.Point(136, 104) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 4 Me.Button2.Text = "&Clear" ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(112, 24) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(112, 56) Me.TextBox2.Name = "TextBox2" Me.TextBox2.TabIndex = 1 Me.TextBox2.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.SystemColors.HotTrack Me.Label1.Location = New System.Drawing.Point(16, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(96, 24) Me.Label1.TabIndex = 4 Me.Label1.Text = "Amount Owed" Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.ForeColor = System.Drawing.SystemColors.HotTrack Me.Label2.ImageAlign = System.Drawing.ContentAlignment.MiddleRight Me.Label2.Location = New System.Drawing.Point(24, 56) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(88, 16) Me.Label2.TabIndex = 5 Me.Label2.Text = "Amount Paid " Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaption Me.Label3.Location = New System.Drawing.Point(16, 240) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(64, 23) Me.Label3.TabIndex = 6 Me.Label3.Text = "Nickels" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'LblBills ' Me.LblBills.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblBills.Location = New System.Drawing.Point(112, 144) Me.LblBills.Name = "LblBills" Me.LblBills.TabIndex = 7 Me.LblBills.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Label5 ' Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.ForeColor = System.Drawing.SystemColors.ActiveCaption Me.Label5.Location = New System.Drawing.Point(16, 272) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(64, 23) Me.Label5.TabIndex = 8 Me.Label5.Text = "Penies" Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label6 ' Me.Label6.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label6.ForeColor = System.Drawing.SystemColors.ActiveCaption Me.Label6.Location = New System.Drawing.Point(16, 208) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(64, 23) Me.Label6.TabIndex = 9 Me.Label6.Text = "Dimes" Me.Label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label7 ' Me.Label7.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label7.ForeColor = System.Drawing.SystemColors.ActiveCaption Me.Label7.Location = New System.Drawing.Point(16, 176) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(64, 23) Me.Label7.TabIndex = 10 Me.Label7.Text = "Quarters" Me.Label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label8 ' Me.Label8.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label8.ForeColor = System.Drawing.SystemColors.ActiveCaption Me.Label8.Location = New System.Drawing.Point(16, 144) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(64, 23) Me.Label8.TabIndex = 11 Me.Label8.Text = "Bills" Me.Label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'LblPenie ' Me.LblPenie.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblPenie.Location = New System.Drawing.Point(112, 272) Me.LblPenie.Name = "LblPenie" Me.LblPenie.TabIndex = 13 Me.LblPenie.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'LblNicke ' Me.LblNicke.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblNicke.Location = New System.Drawing.Point(112, 240) Me.LblNicke.Name = "LblNicke" Me.LblNicke.TabIndex = 14 Me.LblNicke.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'LblDimes ' Me.LblDimes.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblDimes.Location = New System.Drawing.Point(112, 208) Me.LblDimes.Name = "LblDimes" Me.LblDimes.TabIndex = 15 Me.LblDimes.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'LblQuart ' Me.LblQuart.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.LblQuart.Location = New System.Drawing.Point(112, 176) Me.LblQuart.Name = "LblQuart" Me.LblQuart.TabIndex = 16 Me.LblQuart.TextAlign = System.Drawing.ContentAlignment.MiddleCenter ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(226, 327) Me.Controls.Add(Me.LblQuart) Me.Controls.Add(Me.LblDimes) Me.Controls.Add(Me.LblNicke) Me.Controls.Add(Me.LblPenie) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.LblBills) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon) Me.MaximizeBox = False Me.Name = "Form1" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = " ChangeForm" Me.ResumeLayout(False) End Sub #End Region Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Cr Then e.Handled = True MessageBox.Show("Only Numbers!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) End If If e.KeyChar = ControlChars.Cr Then Me.TextBox2.Focus() End If End Sub Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then e.Handled = True Me.Button1.Enabled = True If e.KeyChar = ControlChars.Cr Then Me.Button1.PerformClick() End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.TextBox1.Text = "" Me.TextBox2.Text = "" Me.LblBills.Text = "" Me.LblQuart.Text = "" Me.LblDimes.Text = "" Me.LblNicke.Text = "" Me.LblPenie.Text = "" Me.TextBox1.Focus() Me.Button1.Enabled = False End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.LblBills.Text = "" Me.LblQuart.Text = "" Me.LblDimes.Text = "" Me.LblNicke.Text = "" Me.LblPenie.Text = "" Dim temp As Integer If TextBox2.Text <> "" AndAlso TextBox1.Text <> "" AndAlso TextBox2.Text - TextBox1.Text >= 0 Then temp = (TextBox2.Text - TextBox1.Text) * 100 LblBills.Text = temp \ 100 temp = temp Mod 100 LblQuart.Text = temp \ 25 temp = temp Mod 25 LblDimes.Text = temp \ 10 temp = temp Mod 10 LblNicke.Text = temp \ 5 temp = temp Mod 5 LblPenie.Text = temp Me.Button2.Focus() Else If TextBox2.Text = "" Then MessageBox.Show("Empty Value in the Amount Paid", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Me.TextBox2.Focus() Else If TextBox1.Text = "" Then MessageBox.Show("Empty Value in the Amount Owed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Me.TextBox1.Focus() Else MessageBox.Show("Amount Paid must be greater than Amount Owed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Me.TextBox2.Focus() End If End If End If End Sub End Class