A MsgBox Still Appears After one Closes a UserForm

27/10/2007 - 00:25 por yaguaso | Informe spam
A UserForm with a Textbox has a message Box that indicates that a value has
been entered out range. If ones decide not to enter any value and closes the
UserForm the message still appears even though the closing.
This is the mentioned example (VBA for Excel 2003)

Private Sub TextBox7_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox7.Value < 16 Or TextBox7.Value > 36 Then
MsgBox "El valor de Longitud Axial debe estar entre 16 y 36 mm"
Cancel = True
Else
End If
End Sub

How can be avoided the condition referred.

Preguntas similare

Leer las respuestas

#1 Héctor Miguel
27/10/2007 - 03:53 | Informe spam
hi, anonymous !

(OT): do you really speak only in english? (otherwise)...
-> you should not trust the on-line translators (at least, not literally) ;)
or... post to any english group (i.e. microsoft.public.excel.programming)

so... posting to an spanish group, should I reply in english? (I guess no) -?-

puesto que estas manejando una cancelacion de eventos, una vez modificado el textbox y lanzado el mensaje:

op1: (por fuerza) necesitaras dar entrada a los valores "dentro del rango" (aunque decidas cancelar el formulario)

op2: podrias modificar las condiciones de la cancelacion del evento (p.e.) saltandolo si el textbox esta "vacio"
(obviamente) necesitaras tambien vaciarlo luego de la presentacion del mensaje y ademas...
buscar algun mecanismo de verificacion intermedio antes de continuar (si decides no terminar el formulario)

Private Sub TextBox7_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox7 = "" Then Exit Sub
If Val(TextBox7) < 16 Or Val(TextBox7) > 36 Then
MsgBox "El valor de Longitud Axial debe estar entre 16 y 36 mm"
TextBox7 = ""
Cancel = True
End If
End Sub

si cualquier duda (o informacion adicional)... comentas ?
saludos,
hector.

__ original post __
A UserForm with a Textbox has a message Box that indicates that a value has been entered out range.
If ones decide not to enter any value and closes the UserForm the message still appears even though the closing.
This is the mentioned example (VBA for Excel 2003)

Private Sub TextBox7_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox7.Value < 16 Or TextBox7.Value > 36 Then
MsgBox "El valor de Longitud Axial debe estar entre 16 y 36 mm"
Cancel = True
Else
End If
End Sub

How can be avoided the condition referred.
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida