May be a simple question - UserForm condition


Posted by Dennis on June 17, 2001 7:35 PM

Does anyone know of a way to write a condition where the user will be prompted (msgbox) if a number entered on a userform is not divisible by 4.

For example, 5 is entered...msgbox "Sorry you have entered an invalid value."

If a correct value, say 36 is entered, the application will continue to run.

Thank you in advance.

Posted by Ivan F Moala on June 18, 2001 2:30 AM

On way to do it is;

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
If CInt(TextBox1.Value / 4) <> TextBox1.Value / 4 Then
Cancel = True
TextBox1.Value = ""
End If
End Sub

Ivan



Posted by Dennis on June 18, 2001 1:45 PM

Works Great! - Thanks Ivan