Hanya angka aja

Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000&

Public Function SetNoNumbers(txt As TextBox, Flag As Boolean)
Dim curstyle As Long
Dim newstyle As Long
curstyle = GetWindowLong(txt.hwnd, GWL_STYLE)
If Flag Then
curstyle = curstyle Or ES_NUMBER
Else
curstyle = curstyle And (Not ES_NUMBER)
End If
SetNoNums = SetWindowLong(txt.hwnd, GWL_STYLE, curstyle)
txt.Refresh
End Function

Private Sub Command1_Click()
Call SetNoNumbers(Text1, True)
End Sub

No comments:

Post a Comment