bVerifyValue,

  • 1153
  • 0

摘要:bVerifyValue,

 

要善用tooltips,object name, tag 等載體


 

 

 

    Private Function bVerifyValue(ByVal pRootChk As CheckBox, ByVal pTxtbox As TextBox) As Boolean

        Try

            bVerifyValue = False
            If pRootChk.Checked = True Then
                If pTxtbox.Text = BLANK Then
                    MsgBox("Please key-in " & Me.ToolTip.GetToolTip(pRootChk) & ".", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)

                    pTxtbox.Focus()

                    Exit Function
                Else
                    If bCheckNumber(pTxtbox, Me.ToolTip) = False Then
                        Exit Function
                    End If
                End If

            End If

            bVerifyValue = True
        Catch Err As Exception
            Call ErrHandler(Err.Message, APP_NAME)
        End Try
    End Function

 

    Private Function bSaveBloodTestValue(ByVal pRootChk As CheckBox, ByVal pUnknownChk As CheckBox, ByRef psSaveValue As String, ByVal pTxtbox As TextBox) As Boolean
        Try
            bSaveBloodTestValue = False
            If pRootChk.Checked = True Then
                If pUnknownChk.Checked = True Then
                    psSaveValue = 0
                Else
                    If pTxtbox.Text = BLANK Then
                        MsgBox("Please key-in " & pTxtbox.Name.Replace("txt", BLANK) & ".", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                        pTxtbox.Focus()
                        Exit Function
                    Else
                        If bCheckNumber(pTxtbox, Me.ToolTip) = False Then Exit Function
                    End If
                    psSaveValue = pTxtbox.Text
                End If
            End If
            bSaveBloodTestValue = True
        Catch Err As Exception
            Call ErrHandler(Err.Message, APP_NAME)
        End Try
    End Function

 

Private Function bCheckNumber(ByVal pTxtBox As Object, ByVal pToolTip As ToolTip) As Boolean

        Try
            bCheckNumber = False
            If pTxtBox.text.length > 0 Then
                Dim tempInteger = CInt(pTxtBox.text)

                Dim lsName As String = "The value of " & pToolTip.GetToolTip(pTxtBox) & " should be"
                If pTxtBox.tag <> BLANK Then
                    If pTxtBox.tag.tolower.indexof("dec0") > -1 Then
                        If tempInteger < 1 Or tempInteger > 30 Then
                            MsgBox(lsName & " between 0 and 30.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                            pTxtBox.text = BLANK
                            pTxtBox.focus()
                            Exit Function
                        End If
                    End If
                    If pTxtBox.tag.tolower.indexof("dec2") > -1 Then
                        If pTxtBox.tag.tolower.indexof("val1") > -1 Then
                            If tempInteger < 2 Then
                                MsgBox(lsName & " greater than 1.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                                pTxtBox.text = BLANK
                                pTxtBox.focus()
                                Exit Function
                            End If
                        End If
                        If pTxtBox.tag.tolower.indexof("val5") > -1 Then
                            If tempInteger < 5 Then
                                MsgBox(lsName & " greater than 5.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                                pTxtBox.text = BLANK
                                pTxtBox.focus()
                                Exit Function
                            End If
                        End If
                        If pTxtBox.tag.tolower.indexof("val20") > -1 Then
                            If tempInteger < 20 Then
                                MsgBox(lsName & " greater than 20.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                                pTxtBox.text = BLANK
                                pTxtBox.focus()
                                Exit Function
                            End If
                        End If
                        If pTxtBox.tag.tolower.indexof("val0") > -1 Then
                            If tempInteger < 0 Then
                                MsgBox(lsName & " greater than 0.", MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
                                pTxtBox.text = BLANK
                                pTxtBox.focus()
                                Exit Function
                            End If
                        End If
                    End If
                End If
            End If
            bCheckNumber = True
        Catch Err As Exception
            Call ErrHandler(Err.Message, APP_NAME)
        End Try
    End Function

 

 

 

------------------

熱愛生命 喜愛新奇 有趣的事物

 

過去 是無法改變
將來 卻能夠創造

 

希望使大家生活更便利
世界更美好

 

a guy who loves IT and life