Results 1 to 1 of 1

Thread: Validate Any Control (VB5 or VB6)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Validate Any Control (VB5 or VB6)

    I developed this for VB5 since no validation event.
    Forces return to Control Upon Error.

    Code:
    In Module:
    ----------
    
    
    Public Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
    
    
    Public Sub SetCtrlFocus(hwnd As Long)
    'Set Focus to a control.
    'Forces Validation like VB6
    
        Call Putfocus(hwnd)
    
    End Sub
    
    
    In Control LostFocus Event:
    -----------------------------------------
    (See below for example)
    
    Private Sub tbDataEndDate_LostFocus()
    
       On Error GoTo Error_tbDataEndDate
    
      {Code to check TextBox Input}
       
     
       Exit Sub
       
    Error_tbDataEndDate:
    
      {Error Routine Goes Here}
       
       Call SetCtrlFocus(tbDataEndDate.hwnd)    '<<<<< RETURNS FOCUS IF ERROR
    
    End Sub
    Last edited by dw85745; Jul 11th, 2009 at 12:56 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width