Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: andaluz en 26 Octubre 2010, 20:49 PM

Título: contro de errores
Publicado por: andaluz en 26 Octubre 2010, 20:49 PM
me gustaria que me ayudarais a controlar el error.

Código (vb) [Seleccionar]

On Error GoTo denei
                                               'Código posible error
                                               If Not lbl_d.Caption = lbl_dni1.Caption Then
                                                   error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                   Else
                                                       If Not lbl_d.Caption = lbl_dni2.Caption Then
                                                           error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                       Else
                                                           If Not lbl_d.Caption = lbl_dni3.Caption Then
                                                               error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                           Else
                                                               If Not lbl_d.Caption = lbl_dni4.Caption Then
                                                                   error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                   Else
                                                                       If Not lbl_d.Caption = lbl_dni5.Caption Then
                                                                           error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                       Else
                                                                           If Not lbl_d.Caption = lbl_dni6.Caption Then
                                                                               error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                           Else
                                                                               If Not lbl_d.Caption = lbl_dni7.Caption Then
                                                                                   error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                               Else
                                                                                   If Not lbl_d.Caption = lbl_dni8.Caption Then
                                                                                       error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                                   Else
                                                                                       If Not lbl_d.Caption = lbl_dni9.Caption Then
                                                                                           error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                                       Else
                                                                                           If Not lbl_d.Caption = lbl_dni10.Caption Then
                                                                                               error = MsgBox("DNI no registrado", vbExclamation, "Error")
                                                                                       End If
                                                                                   End If
                                                                               End If
                                                                           End If
                                                                       End If
                                                                   End If
                                                           End If
                                                       End If
                                               End If


el error creo que esta en la primera línea
Código (vb) [Seleccionar]
On Error GoTo denei pero nose como arreglar este error.

saludos
Título: Re: contro de errores
Publicado por: ignorantev1.1 en 26 Octubre 2010, 21:26 PM
Por que no crear un array de controles?
Código (vb) [Seleccionar]

 dim i as integer
 for i=1 to 10
    if not lbl_d.caption=lbl_dni(i).caption then  goto denei
  next
denei:
  MsgBox "DNI no registrado", vbExclamation, "Error"