Validaciju radiš u BeforeUpdate događaju umesto Exit
Cancel u tom slučaju je parametar Event procedure i služi da fokus ostane na aktivnoj kontroli
Code:
Private Sub txtVisina_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = False
Validate Cancel
End Sub
Private Sub txtSirina_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = False
Validate Cancel
End Sub
Private Sub Validate(ByRef Cancel As MSForms.ReturnBoolean)
' Procedura za validaciju vrednosti text boxa
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Value) Or (IsNumeric(.Value) And (.Value < 300 Or .Value > 6000)) Then
MsgBox "Invalid input. Please enter a number b/w 300 and 6000.", vbCritical
'.Value = vbNullString
Cancel = True 'prevent AfterUpdate and focus moving
.SetFocus
End If
End With
End If
End Sub
Nije to loše Rembrante, samo što ne bi dodao još malo boje?