Private iStatus As Integer = 0
Private bIsKeyboardInput As Boolean = False
Private iTxtLen As Integer = 0
Private Sub txtPayDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPayDay.TextChanged
SSLog.MethodStartLog(GetCurrentMethod())
'If Me.txtPayDay.Text.IndexOf("/") <> -1 Or Me.txtPayDay.Text.Length > 4 Then
CheckDate4Y()
Me.iTxtLen = Me.txtPayDay.Text.Length
' End If
SSCommon.Util.SSLog.MethodEndLog(GetCurrentMethod)
End Sub
Private Sub txtPayDay_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPayDay.KeyDown
If e.KeyValue = 8 Then
iStatus = 1
End If
End Sub
Private Sub txtPayDay_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPayDay.KeyUp
Select Case e.KeyCode
Case Keys.D0, Keys.D1, _
Keys.D2, Keys.D3, _
Keys.D4, Keys.D5, _
Keys.D6, Keys.D7, _
Keys.D8, Keys.D9, _
Keys.NumPad0, _
Keys.NumPad1, _
Keys.NumPad2, _
Keys.NumPad3, _
Keys.NumPad4, _
Keys.NumPad5, _
Keys.NumPad6, _
Keys.NumPad7, _
Keys.NumPad8, _
Keys.NumPad9
Me.bIsKeyboardInput = True
Case Else
End Select
iStatus = 0
End Sub
Private Function CheckDate4Y() As Boolean
Dim a, b, c As String
'---------------------------------------------------------------------------
'Year Control
'---------------------------------------------------------------------------
If Microsoft.VisualBasic.Len(Me.txtPayDay.Text) = 1 Then
If IsNumeric(Microsoft.VisualBasic.Left((Me.txtPayDay.Text), 1)) = False _
Or Microsoft.VisualBasic.Left((Me.txtPayDay.Text), 1) = "0" Then
Me.txtPayDay.Text = ""
End If
End If
If Microsoft.VisualBasic.Len(txtPayDay.Text) = 2 _
Or Microsoft.VisualBasic.Len(txtPayDay.Text) = 3 _
Or Microsoft.VisualBasic.Len(txtPayDay.Text) = 4 Then
If Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "0" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "1" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "2" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "3" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "4" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "5" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "6" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "7" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "8" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "9" Then
'If txtPayDay.Text.IndexOf("/") = -1 Then
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), _
Len(txtPayDay.Text) - 1)
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
' End If
End If
End If
If Me.iTxtLen = 5 Then
Else
If Microsoft.VisualBasic.Len(txtPayDay.Text) = 4 Then
If txtPayDay.Text.IndexOf("/") = -1 Then
txtPayDay.Text = txtPayDay.Text + "/"
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
End If
End If
End If
'---------------------------------------------------------------------------
'Month Control
'---------------------------------------------------------------------------
If Microsoft.VisualBasic.Len(txtPayDay.Text) = 5 Then
If txtPayDay.Text.IndexOf("/") = -1 Then
a = Microsoft.VisualBasic.Right((txtPayDay.Text), 1)
If a <> "0 " And a <> "1" Then
If a = "2" _
Or a = "3" _
Or a = "4" _
Or a = "5" _
Or a = "6" _
Or a = "7" _
Or a = "8" _
Or a = "9" Then
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), 4) + "/" + "0" + a
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
End If
Else
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), 4) + "/" + a
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
End If
Return False
Else
Return False
End If
End If
If Microsoft.VisualBasic.Len(txtPayDay.Text) = 6 Then
If Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "0" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "1" Then
'txtPayDay.Text = txtPayDay.Text.Remove(Microsoft.VisualBasic.Len(txtPayDay.Text) - 1, 1)
If Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "2" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "3" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "4" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "5" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "6" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "7" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "8" _
Or Microsoft.VisualBasic.Right((txtPayDay.Text), 1) = "9" Then
'If txtPayDay.Text.IndexOf("/") = -1 Then
a = Microsoft.VisualBasic.Right((txtPayDay.Text), 1)
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), 5) + "0" + a '+ "/"
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
'End If
Else
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), _
Microsoft.VisualBasic.Len(txtPayDay.Text) - 1)
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
End If
End If
End If
If Microsoft.VisualBasic.Len(txtPayDay.Text) = 7 Then
If Microsoft.VisualBasic.Left(Microsoft.VisualBasic.Right(txtPayDay.Text, 2), 1) = "0" Then
If Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "1" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "2" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "3" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "4" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "5" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "6" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "7" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "8" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "9" Then
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), _
Microsoft.VisualBasic.Len(txtPayDay.Text) - 1)
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
Else
txtPayDay.Text = txtPayDay.Text '+ "/"
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
Exit Function
End If
End If
If Microsoft.VisualBasic.Left(Microsoft.VisualBasic.Right((txtPayDay.Text), 2), 1) = "1" Then
If Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "0" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "1" _
And Microsoft.VisualBasic.Right((txtPayDay.Text), 1) <> "2" Then
txtPayDay.Text = Microsoft.VisualBasic.Left((txtPayDay.Text), _
Microsoft.VisualBasic.Len(txtPayDay.Text) - 1)
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
Else
txtPayDay.Text = txtPayDay.Text '+ "/"
txtPayDay.SelectionStart = Microsoft.VisualBasic.Len(txtPayDay.Text)
End If
End If
End If
End Function
#End Region