I am writing a VBA code that is opened from a UserForm, which includes 2 ComboBoxes and 2 TextBoxes to form a 2D matrix by user's choice.
What I'm trying to do is, have a variable get the combobox value (one variable for each combobox) and if the selection is null, then the variables get the value of the textboxes. I've googled the expression I need to use for that and stumbled upon IsNull, but the code doesn't work. What I tried was:
If IsNull(Matrix_Size_1.value) = False And IsNull(Matrix_Size_2.value) = False Then
lWidth = Matrix_Size_1.value
lHeight = Matrix_Size_2.value
ElseIf IsNull(Matrix_Size_1.value) = True And IsNull(Matrix_Size_2.value) = True Then
lWidth = Matrix_Hand_1.value
lHeight = Matrix_Hand_2.value
End If
Of course I also have to filter more plausible situations as: if one combobox is empty then msgbox, if everything is empty then msgbox but I'll handle it once I'll understand why my code doesn't work.
But the error I get if I DO NOT choose anything from the comboboxes is Type mismatch even though the If code has an option for both of the comboboxes to be empty.
I'd appreciate your help.
ListIndexProperty from the combobox control. If i recall, if ListIndex = -1 then the box has had no value selected. - Takarii