for Currency or with Decimal Point
I was able to get API codes in this site on how to set the text box to accept numerical inputs only, but unfortunately it also disallows the user to input a decimal point or period. What modifications do I need to make to allow the user to input the decimal point?
Here is the code that I got:
Private Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long)
Private Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dNewLong As Long)
Private Const ES_NUMBER = &H2000&
Private Const GWL_STYLE = (-16)
Public Sub makeNumeric(ByRef refTextBox As TextBox)
'makes the textbox numeric only
Dim tmpValue&
Dim fAlignment&
Dim ret&
fAlignment& = ES_NUMBER
tmpValue& = GetWindowLong&(refTextBox.hWnd, GWL_STYLE)
ret& = SetWindowLong&(refTextBox.hWnd, GWL_STYLE, tmpValue& Or fAlignment&)
refTextBox.Refresh
End Sub
Thank you.