摘要:My Library
Public Sub MsgBoxOkOnly(ByVal psMsg As String)
Try
MsgBox(psMsg, MsgBoxStyle.Information + MsgBoxStyle.OKOnly, APP_NAME)
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Sub
Public Function RemoveLastCharInTextBox(ByVal pTxtBox As Object)
' Function to Remove the last Char in TextBox and Cursor focus after last Char.
Try
If pTxtBox.text <> BLANK Then
pTxtBox.text = pTxtBox.text.substring(0, pTxtBox.text.length - 1)
pTxtBox.SelectionStart = pTxtBox.text.length
pTxtBox.focus()
End If
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Function
Public Function bIsNumber(ByVal psValue As String) As Boolean
' Function to check the input string is Number or not
Try
bIsNumber = False
Try
If psValue <> BLANK Then
Dim liValue As Integer = CInt(psValue)
End If
Catch ex As Exception
Call MsgBoxOkOnly("Please key-in Number.")
Exit Function
End Try
bIsNumber = True
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Function
Public Function bCheckDecimalInTextBox(ByVal pTxtBox As Object, ByVal piAllowDecimal As Integer) As Boolean
' Function to do decimal validation in Text Box (0,1,2,3...Decimal also work)
Try
bCheckDecimalInTextBox = False
If bIsNumber(pTxtBox.text) = False Then
Call RemoveLastCharInTextBox(pTxtBox)
Exit Function
End If
If pTxtBox.text <> BLANK Then
Dim liPosition As Integer = pTxtBox.text.indexof(".")
If liPosition > -1 Then
If piAllowDecimal = 0 Then
Call MsgBoxOkOnly("No decimal is allowed")
Call RemoveLastCharInTextBox(pTxtBox)
Else
If pTxtBox.text.length - liPosition > piAllowDecimal + 1 Then
Call MsgBoxOkOnly((piAllowDecimal).ToString & " decimal(s) is allowed")
Call RemoveLastCharInTextBox(pTxtBox)
Exit Function
End If
End If
End If
End If
bCheckDecimalInTextBox = True
Catch Err As Exception
Call ErrHandler(Err.Message, APP_NAME)
End Try
End Function
------------------
熱愛生命 喜愛新奇 有趣的事物
過去 是無法改變
將來 卻能夠創造
希望使大家生活更便利
世界更美好
a guy who loves IT and life
Public
' Function