The following code apply ES_NUMBER to allow only digits to be typed into the edit control.
Public Const GWL_STYLE As Int32 = (-16)
Public Const ES_NUMBER As Int32 = &H2000
<DllImport("User32.dll", EntryPoint:="GetWindowLong")> _
End Function
<DllImport("User32.dll", EntryPoint:="GetWindowLong")> _
End Function
'accept only digit in the specified textbox
Public Sub SetNumericInputMode(ByVal txtBox As TextBox)
Dim style As Int32 = GetWindowLong(txtBox.Handle, GWL_STYLE)
SetWindowLong(txtBox.Handle, GWL_STYLE, style Or ES_NUMBER)
End Sub
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.