SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
Input validation is an important part of any application as data entered by the user must be verified and validated. SftMask/OCX has a number of features designed to assist an application to validate input data.
Generally, a suitable input mask is defined using the Mask property. Optionally, the MessageEmpty and MessageInvalid properties can be defined to provide error messages. SftMask/OCX will never automatically display an error message.
An application can use the Contents.Valid property to determine if a control's input data is valid. If the equivalent ValidMsg property is used instead, a suitable error message is displayed (based on the MessageEmpty and MessageInvalid properties).
The ValidationError event occurs when various error conditions are detected.
An application must explicitly call the Contents.Valid (or ValidMsg) property to insure that the input is valid and display an error message if necessary. It is strongly discouraged to implement this in an event such as LostFocus, WM_KILLFOCUS, FocusOut, etc. as this would prevent a user from clicking on a Cancel button, close the window, etc. unless valid input is entered first. Validation of input data should typically take place in response to the user clicking on an OK, Apply or Save button.
This example assumes an ADO Data Control (Adodc1), two masked edit controls, a Next and a Previous button for record navigation on the form. Some properties, such as Mask, MessageEmpty and MessageInvalid are set at design-time using the property pages).
Function CheckInputFields() As Boolean ' validate all input fields CheckInputFields = False If Not SftMask1.Contents.ValidMsg Then Exit Function If Not SftMask2.Contents.ValidMsg Then Exit Function CheckInputFields = True End Function Private Sub PrevButton_Click() If Not CheckInputFields() Then Exit Sub If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MovePrevious If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst End If End If End Sub Private Sub NextButton_Click() If Not CheckInputFields() Then Exit Sub If Not Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveNext If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast End If End If End Sub