5
« on: March 30, 2017, 09:48:55 PM »
I went ahead and made my own new keypad for pins since I couldn't fix that issue.
frmKeypad.vb
Public Class frmKeypad
Private ValueTxt As String
Public Value As Integer
Public PasswordChar As Boolean
Public MinValue As Integer
Public MaxValue As Integer
Public MaxDigits As Integer
Private Sub frmKeypad_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.ValueTxt = ""
End Sub
' Check if the value is within the range
Private Sub validateValue()
Dim Parse As Boolean = Integer.TryParse(Me.ValueTxt, Me.Value)
If Parse = False Then
Me.ValueTxt = ""
Me.Value = 0
End If
If (MaxValue And Me.Value > MaxValue) Or (MaxDigits And Me.ValueTxt.Length > MaxDigits) Then
If Me.ValueTxt.Length > 0 Then
Me.ValueTxt = Me.ValueTxt.Trim().Remove(Me.ValueTxt.Length - 1)
End If
End If
If MinValue And Me.Value < MinValue Then
Me.ValueTxt = ""
Me.Value = 0
End If
End Sub
Private Sub redrawDisplay()
If Me.PasswordChar Then
Me.display.Text = ""
If Me.ValueTxt.Length > 0 Then
For i = 0 To Me.ValueTxt.Length - 1
Me.display.Text += "*"
Next
End If
Else
Me.display.Text = Me.ValueTxt
End If
End Sub
Private Sub buttonClear_Click(sender As Object, e As EventArgs) Handles buttonClear.Click
Me.ValueTxt = ""
Me.redrawDisplay()
End Sub
Private Sub buttonQuit_Click(sender As Object, e As EventArgs) Handles buttonQuit.Click
Me.DialogResult = DialogResult.Cancel
Me.Close()
End Sub
Private Sub buttonEnter_Click(sender As Object, e As EventArgs) Handles buttonEnter.Click
Me.DialogResult = DialogResult.OK
Dim Parse As Boolean = Integer.TryParse(Me.ValueTxt, Me.Value)
If Parse = False Then
Me.Value = 0
End If
Me.Close()
End Sub
Private Sub buttonBackspace_Click(sender As Object, e As EventArgs) Handles buttonBackspace.Click
If Me.ValueTxt.Length > 0 Then
Me.ValueTxt = Me.ValueTxt.Trim().Remove(Me.ValueTxt.Length - 1)
End If
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num1_Click(sender As Object, e As EventArgs) Handles num1.Click
Me.ValueTxt += "1"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num2_Click(sender As Object, e As EventArgs) Handles num2.Click
Me.ValueTxt += "2"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num3_Click(sender As Object, e As EventArgs) Handles num3.Click
Me.ValueTxt += "3"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num4_Click(sender As Object, e As EventArgs) Handles num4.Click
Me.ValueTxt += "4"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num5_Click(sender As Object, e As EventArgs) Handles num5.Click
Me.ValueTxt += "5"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num6_Click(sender As Object, e As EventArgs) Handles num6.Click
Me.ValueTxt += "6"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num7_Click(sender As Object, e As EventArgs) Handles num7.Click
Me.ValueTxt += "7"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num8_Click(sender As Object, e As EventArgs) Handles num8.Click
Me.ValueTxt += "8"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num9_Click(sender As Object, e As EventArgs) Handles num9.Click
Me.ValueTxt += "9"
Me.validateValue()
Me.redrawDisplay()
End Sub
Private Sub num0_Click(sender As Object, e As EventArgs) Handles num0.Click
Me.ValueTxt += "0"
Me.validateValue()
Me.redrawDisplay()
End Sub
End Class
frmKeypad.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmKeypad
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmKeypad))
Me.num1 = New System.Windows.Forms.Button()
Me.num2 = New System.Windows.Forms.Button()
Me.num3 = New System.Windows.Forms.Button()
Me.num4 = New System.Windows.Forms.Button()
Me.num5 = New System.Windows.Forms.Button()
Me.num6 = New System.Windows.Forms.Button()
Me.num7 = New System.Windows.Forms.Button()
Me.num8 = New System.Windows.Forms.Button()
Me.num9 = New System.Windows.Forms.Button()
Me.num0 = New System.Windows.Forms.Button()
Me.buttonClear = New System.Windows.Forms.Button()
Me.buttonQuit = New System.Windows.Forms.Button()
Me.buttonEnter = New System.Windows.Forms.Button()
Me.display = New System.Windows.Forms.Label()
Me.Title = New System.Windows.Forms.Label()
Me.buttonBackspace = New System.Windows.Forms.Button()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.SuspendLayout()
'
'num1
'
Me.num1.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num1.Location = New System.Drawing.Point(11, 83)
Me.num1.Name = "num1"
Me.num1.Size = New System.Drawing.Size(40, 40)
Me.num1.TabIndex = 0
Me.num1.Text = "1"
Me.num1.UseVisualStyleBackColor = True
'
'num2
'
Me.num2.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num2.Location = New System.Drawing.Point(57, 83)
Me.num2.Name = "num2"
Me.num2.Size = New System.Drawing.Size(40, 40)
Me.num2.TabIndex = 1
Me.num2.Text = "2"
Me.num2.UseVisualStyleBackColor = True
'
'num3
'
Me.num3.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num3.Location = New System.Drawing.Point(103, 83)
Me.num3.Name = "num3"
Me.num3.Size = New System.Drawing.Size(40, 40)
Me.num3.TabIndex = 2
Me.num3.Text = "3"
Me.num3.UseVisualStyleBackColor = True
'
'num4
'
Me.num4.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num4.Location = New System.Drawing.Point(11, 129)
Me.num4.Name = "num4"
Me.num4.Size = New System.Drawing.Size(40, 40)
Me.num4.TabIndex = 3
Me.num4.Text = "4"
Me.num4.UseVisualStyleBackColor = True
'
'num5
'
Me.num5.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num5.Location = New System.Drawing.Point(57, 129)
Me.num5.Name = "num5"
Me.num5.Size = New System.Drawing.Size(40, 40)
Me.num5.TabIndex = 4
Me.num5.Text = "5"
Me.num5.UseVisualStyleBackColor = True
'
'num6
'
Me.num6.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num6.Location = New System.Drawing.Point(103, 129)
Me.num6.Name = "num6"
Me.num6.Size = New System.Drawing.Size(40, 40)
Me.num6.TabIndex = 5
Me.num6.Text = "6"
Me.num6.UseVisualStyleBackColor = True
'
'num7
'
Me.num7.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num7.Location = New System.Drawing.Point(11, 175)
Me.num7.Name = "num7"
Me.num7.Size = New System.Drawing.Size(40, 40)
Me.num7.TabIndex = 6
Me.num7.Text = "7"
Me.num7.UseVisualStyleBackColor = True
'
'num8
'
Me.num8.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num8.Location = New System.Drawing.Point(57, 175)
Me.num8.Name = "num8"
Me.num8.Size = New System.Drawing.Size(40, 40)
Me.num8.TabIndex = 7
Me.num8.Text = "8"
Me.num8.UseVisualStyleBackColor = True
'
'num9
'
Me.num9.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num9.Location = New System.Drawing.Point(103, 175)
Me.num9.Name = "num9"
Me.num9.Size = New System.Drawing.Size(40, 40)
Me.num9.TabIndex = 8
Me.num9.Text = "9"
Me.num9.UseVisualStyleBackColor = True
'
'num0
'
Me.num0.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.num0.Location = New System.Drawing.Point(57, 221)
Me.num0.Name = "num0"
Me.num0.Size = New System.Drawing.Size(40, 40)
Me.num0.TabIndex = 9
Me.num0.Text = "0"
Me.num0.UseVisualStyleBackColor = True
'
'buttonClear
'
Me.buttonClear.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.buttonClear.Location = New System.Drawing.Point(166, 83)
Me.buttonClear.Name = "buttonClear"
Me.buttonClear.Size = New System.Drawing.Size(84, 40)
Me.buttonClear.TabIndex = 10
Me.buttonClear.Text = "Clear"
Me.buttonClear.UseVisualStyleBackColor = True
'
'buttonQuit
'
Me.buttonQuit.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.buttonQuit.Location = New System.Drawing.Point(166, 129)
Me.buttonQuit.Name = "buttonQuit"
Me.buttonQuit.Size = New System.Drawing.Size(84, 40)
Me.buttonQuit.TabIndex = 11
Me.buttonQuit.Text = "Quit"
Me.buttonQuit.UseVisualStyleBackColor = True
'
'buttonEnter
'
Me.buttonEnter.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.buttonEnter.Location = New System.Drawing.Point(166, 221)
Me.buttonEnter.Name = "buttonEnter"
Me.buttonEnter.Size = New System.Drawing.Size(84, 40)
Me.buttonEnter.TabIndex = 12
Me.buttonEnter.Text = "Enter"
Me.buttonEnter.UseVisualStyleBackColor = True
'
'display
'
Me.display.BackColor = System.Drawing.SystemColors.Info
Me.display.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.display.Font = New System.Drawing.Font("Consolas", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.display.Location = New System.Drawing.Point(12, 41)
Me.display.Name = "display"
Me.display.Size = New System.Drawing.Size(238, 27)
Me.display.TabIndex = 13
Me.display.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Title
'
Me.Title.BackColor = System.Drawing.SystemColors.ControlDark
Me.Title.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Title.Location = New System.Drawing.Point(12, 9)
Me.Title.Name = "Title"
Me.Title.Size = New System.Drawing.Size(238, 23)
Me.Title.TabIndex = 14
Me.Title.Text = "Password"
Me.Title.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'buttonBackspace
'
Me.buttonBackspace.Font = New System.Drawing.Font("Arial", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.buttonBackspace.Location = New System.Drawing.Point(103, 221)
Me.buttonBackspace.Name = "buttonBackspace"
Me.buttonBackspace.Size = New System.Drawing.Size(40, 40)
Me.buttonBackspace.TabIndex = 15
Me.buttonBackspace.Text = "C"
Me.buttonBackspace.UseVisualStyleBackColor = True
'
'Panel1
'
Me.Panel1.BackColor = System.Drawing.SystemColors.ControlDark
Me.Panel1.Location = New System.Drawing.Point(6, 7)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(250, 260)
Me.Panel1.TabIndex = 16
'
'frmKeypad
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.ControlDarkDark
Me.ClientSize = New System.Drawing.Size(263, 273)
Me.Controls.Add(Me.buttonBackspace)
Me.Controls.Add(Me.Title)
Me.Controls.Add(Me.display)
Me.Controls.Add(Me.buttonEnter)
Me.Controls.Add(Me.buttonQuit)
Me.Controls.Add(Me.buttonClear)
Me.Controls.Add(Me.num0)
Me.Controls.Add(Me.num9)
Me.Controls.Add(Me.num8)
Me.Controls.Add(Me.num7)
Me.Controls.Add(Me.num6)
Me.Controls.Add(Me.num5)
Me.Controls.Add(Me.num4)
Me.Controls.Add(Me.num3)
Me.Controls.Add(Me.num2)
Me.Controls.Add(Me.num1)
Me.Controls.Add(Me.Panel1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "frmKeypad"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Keypad"
Me.ResumeLayout(False)
End Sub
Friend WithEvents num1 As Button
Friend WithEvents num2 As Button
Friend WithEvents num3 As Button
Friend WithEvents num4 As Button
Friend WithEvents num5 As Button
Friend WithEvents num6 As Button
Friend WithEvents num7 As Button
Friend WithEvents num8 As Button
Friend WithEvents num9 As Button
Friend WithEvents num0 As Button
Friend WithEvents buttonClear As Button
Friend WithEvents buttonQuit As Button
Friend WithEvents buttonEnter As Button
Friend WithEvents display As Label
Friend WithEvents Title As Label
Friend WithEvents buttonBackspace As Button
Friend WithEvents Panel1 As Panel
End Class