Martin,
I use both options 2 and 3.
My class has properties mapping to the appropriate fields of a table (or
group of tables). The class handles all of the database reads and writes.
I "tie" each input control to a field using the DataField property of the
control(most of them have it).
Finally, in the Validate event of each of the controls, I add any "form"
specific validations and then use the CallByName function (utilizing the
values I've placed in the DataField property) to update the properties in
the instance of the class. The class then handles "database" validations.
Mind you that I use control arrays extensively here.
So I use the validate event of the controls to interact with the properties
of my class (most of the time... hehehe).
There are instances I do use the Change event of the control depending on
the form/data behavior I want to achieve.
Just my thoughts.
Regards,
Rommel
PS: The fields on my forms are *not* (directly) bound to a database source.
The class builds and executes the Update/Insert/Delete SQL statements.
-----Original Message-----
From: martin.scullion@u...
[mailto:martin.scullion@u...]
Sent: Monday, September 30, 2002 9:48 AM
To: professional vb
Subject: [pro_vb] Data validation
I have a simple data input type form, the data from which requires simple
validation rules, now my question is this where do I put the validation.
I have several options :-
1). On the form itself invoked by a click event.
2). The fields will be passed to a class so I could alternatively validate
at the property let Procedure.
3). On_Validate event
My Personal preference is option 2 as I can then control the validation in
one area (The Class Module) and throw errors as appropriate.
Has anyone else any thoughts ???
---
Visual C# - A Guide for VB6 Developers
This book will make it easy to transfer your skills
from Visual Basic 6 to C#, the language of choice
of the .NET Framework.
http://www.wrox.com/ACON11.asp?ISBN=1861007175&p2p0059