September 23, 2018
Hot Topics:

VB Coding Tip: Only Allow Numbers in a Nodes Text

  • November 18, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

This treeview tip again uses the SendMessage API call to find the edit window in the treeview and then send a message to it, the ES_NUMBER message to only allow numbers.

Private Declare Function SendMessage _
     Lib "user32" Alias _
  "SendMessageA" (ByVal hwnd As Long, _
                  ByVal wMsg As Long, ByVal _
                  wParam As Long, _
                  lParam As Any) As Long

Private Const TV_FIRST = &H1100
                              TV_FIRST + 15
Private Const ES_NUMBER = &H2000

Private Sub NumbersOnly(tvw As Treeview)
    Dim lngHwnd As Long  

    lngHwnd = SendMessage(tvw.hwnd, _
                          TVM_GETEDITCONTROL, _
                          0, 0)

    If lngHwnd <> 0 Then
        SendMessage lngHwnd, ES_NUMBER, 0, 0
    End If
End Sub

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date