web development India freelance website designer
Make a new project. To the form add a text box and a command button.

Code:
Add this code to the form's General Declarations procedure:

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

Add this code to the command button:

Private Sub Command1_Click()
Call SetNoNumbers(Text1, True)
End Sub
Only allow numbers in a TextBox

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550

Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design