Skip to content

Run-time error '13': Type mismatch #10

@tothzola

Description

@tothzola

error

Hello, If I want to implement a validation to ComboBox control
and have the following error: Run-time error '13': Type mismatch on this line when it evaluates to TRUE:

If Not Validator Is Nothing Then
    BindingBase.AsINotifyValidationError.RegisterHandler ValidationManager
End If

BindPropertyPath:

Context.Bindings.BindPropertyPath ViewModel, "ComboBoxItemIndex", Me.ComboBox, _
            Mode:=TwoWayBinding, _
            UpdateTrigger:=OnPropertyChanged, _
            Validator:=New RequiredSelectionValidator, _
            ValidationAdorner:=ValidationErrorAdorner.Create(Target:=Me.ComboBox, _
            TargetFormatter:=ValidationErrorFormatter.WithErrorBorderColor.WithErrorBackgroundColor)

RequiredSelectionValidator Class:

'@ModuleDescription "A validator that requires a ComboBox Item to be selected."
Option Explicit

Implements IValueValidator

Private Function IValueValidator_IsValid(ByVal value As Variant, ByVal Source As IBindingPath, ByVal Target As IBindingPath) As Boolean
    IValueValidator_IsValid = value > -1
End Function

Private Property Get IValueValidator_Message() As String
    IValueValidator_Message = "Value cannot be empty."
End Property

Private Property Get IValueValidator_Trigger() As BindingUpdateSourceTrigger
    IValueValidator_Trigger = OnExit
End Property

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions