YYYY/MM

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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值