G
Guest
Hello
I am switching my courses from VB 6 to VB.Net. I teach my students to place validation inside the class. If data is invalid, then I want to raise an event in the form. This works fine when done from the Set property of a data member. I want to code a parameterized constructor so the user of the class can set initial values. I placed data validation in the constructor but it will not raise the event from the constructor. I tried creating a separate routine, say ValidateName and firing the event from there. This procedure works when it is called from the Set property. It does not work when it is called from the constructor.
If what I want to do is not possible, then what is the standard way of handling this? I teach my students not to use a messagebox or a form control inside the class because the class should be reusable. Also, I want to user of the class to handle invalid data as they see fit and raising an event solves that
Thanks in advance
Jani
I am switching my courses from VB 6 to VB.Net. I teach my students to place validation inside the class. If data is invalid, then I want to raise an event in the form. This works fine when done from the Set property of a data member. I want to code a parameterized constructor so the user of the class can set initial values. I placed data validation in the constructor but it will not raise the event from the constructor. I tried creating a separate routine, say ValidateName and firing the event from there. This procedure works when it is called from the Set property. It does not work when it is called from the constructor.
If what I want to do is not possible, then what is the standard way of handling this? I teach my students not to use a messagebox or a form control inside the class because the class should be reusable. Also, I want to user of the class to handle invalid data as they see fit and raising an event solves that
Thanks in advance
Jani