Autor Tema: Comprobar campo obligatorio - nulo o con errores  (Leído 2400 veces)

0 Usuarios y 1 Visitante están viendo este tema.

zxs23

  • Megabyte
  • ***
  • Mensajes: 146
  • Reputación: +5/-2
    • Ver Perfil
Comprobar campo obligatorio - nulo o con errores
« en: Septiembre 15, 2012, 08:57:27 pm »
Como podria optimizar este codigo, tomando en cuenta que puedo tener mas texbox los cuales no necesariamente son obligatorios y pueden quedar en blanco.
Código: [Seleccionar]
If Text2 = "" Then
      MsgBox "El campo nombre es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
   ElseIf txtPrecio = "0.00" Or txtPrecio = "0,00" Or txtPrecio = "" Then
      MsgBox "El campo Precio es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
   ElseIf Text3 = "" Then
      MsgBox "El campo descrip. corta es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
   ElseIf Text4 = "" Then
      MsgBox "El campo stock es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
   ElseIf Text5 = "" Then
      MsgBox "El campo categoria es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
   ElseIf Text6 = "" Then
      MsgBox "El campo doc es obligatorio", vbCritical, "Datos incompletos"
      Exit Sub
Else
   '--INSERT--
End If