Steve, If I remember correctly form some of your previous posts, you are not yet comfortable working with objects and classes (my apologies if I am wrong about that).
But if that is the case, you could perhaps resort to a brute force method.
Are all 24 textboxes on the same form? If so, consider using the macro recorder to paste the required code into each of the relevant events:
1. First, write the code for the Valid - it doesn't matter where you put it. Then copy it to the clipboard.
2. Open the form in the Form Designer. Click on the first textbox.
3. Start the macro recorder. Record a macro which records the keystrokes (not mouse clicks) for the following actions:
- Open the code window (ALT+V then C)
- Navigate to the Procedure drop-down (ALT+R).
- Navigate to the Valid event (V then ENTER) (this assumes that the textbox has no other events or methods that begin with V).
- Paste the contents of the clipboard.
- Close the edit window (ESC)
4. Stop recording.
Now click on each of the texboxes in turn. Press the key that activates the macro (which you would have specified when you started recording).
When you've done them all, save and close the form.
If the texboxes are spread over multiple forms, the same method could be used, but you would have to manually open each form in the designer.
There just remains the question of any future textboxes you create. One way to handle that would be to copy and paste an existing textbox (one with the required Valid code) when you need a new one.
The above might sound a bit fiddly. Perhaps someone will come up with a better suggestion. Otherwise you could give it a try.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads