HeaderPane
Main
Hide
Share Link
Print

Sample4 Sample (VB.NET)

This sample illustrates input validation.

The source code is located at C:\Program Files (x86)\Softelvdm\SftMask OCX 8.0\Samples\Visual Studio - VB.NET\Sample4\Form1.vb.

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each c As Control In Controls
            Dim mask As AxSftMaskLib80.AxSftMask = TryCast(c, AxSftMaskLib80.AxSftMask)
            If mask IsNot Nothing Then
                mask.DarkMode = SftMaskLib80.SftMaskDarkModeConstants.darkSftMaskAuto ' follow the Windows dark mode setting
                mask.HighContrastMode = SftMaskLib80.SftMaskHighContrastConstants.highContrastSftMaskAuto ' follow the Windows High Contrast setting
            End If
        Next
    End Sub

    Private Sub buttonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonCancel.Click
        Application.Exit()
    End Sub

    Private Sub buttonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonOK.Click
        If axSftMaskName.Contents.Valid And _
                axSftMaskCompany.Contents.Valid And _
                axSftMaskZIP.Contents.Valid And _
                axSftMaskTelephone.Contents.Valid And _
                axSftMaskDate.Contents.Valid And _
                axSftMaskAmount.Contents.Valid Then
            ' save the data
            Application.Exit() '  and exit
        Else
            MessageBox.Show("There are validation errors - Please correct the data entered.")
        End If
    End Sub

    Private Sub axSftMaskZIP_CustomValidation(ByVal sender As Object, ByVal e As AxSftMaskLib80._ISftMaskEvents_CustomValidationEvent) Handles axSftMaskZIP.CustomValidation
        If axSftMaskZIP.Text <> "11111" Then
            e.cancel = True
        End If
    End Sub
End Class

Last Updated 11/15/2026 - (email)
© 2026 Softel vdm, Inc.