>Hello,
>
>In a VB 6 application that I am writing, I have code in a LostFocus of a text box control which checks to see that the entry is valid. This code works well, but I now have a problem. If the user enters any text and then presses Cancel, then the code to check if the entry is valid is not needed. So I need a way in the LostFocus event to check if the control that has been pressed (causing the LostFocus event to be called) is the Cancel button. If it is Cancel then I don't need to run the validation code.
You can check the active control:
Private Sub Text1_LostFocus()
If Screen.ActiveControl.Name = "cmdCancel" Then Exit Sub
'Other validations here
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com