[ Foro de BASIC ]

Error No se ha declarado el nombre en Visual Basic

21-Oct-2015 23:20
Saulo David Jorgez
3 Respuestas

Estoy haciendo una base de datos con access y visual basic y me da este error, no entiendo que hacer. Declaré la variable y me sigue dando el error. aquí el código de lo que he hecho hasta ahora. Quería hacer una prueba pero me da este error


Public Class Form1

    Public accion As String
    Public sql As String

    Private Sub AFILIADOSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFILIADOSBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.AFILIADOSBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ASAPROVEDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: esta línea de código carga datos en la tabla 'ASAPROVEDataSet.AFILIADOS' Puede moverla o quitarla según sea necesario.
        Me.AFILIADOSTableAdapter.Fill(Me.ASAPROVEDataSet.AFILIADOS)

    End Sub

    Private Sub CALLETextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CALLETextBox.TextChanged

    End Sub

    Private Sub CALLELabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        NÚMERO.text = ""
        NÚMERO.Enabled = True
        NOMBRES.text = ""
        NOMBRES.Enabled = True
        APELLIDOS.text = ""
        APELLIDOS.Enabled = True
        PROFESIÓN.text = ""
        PROFESIÓN.Enabled = True
        CÉDULA.text = ""
        CÉDULA.Enabled = True
        RESIDENCIA.text = ""
        RESIDENCIA.Enabled = True
        CALLE.text = ""
        CALLE.Enabled = True
        CASA.text = ""
        CASA.Enabled = True
        CIUDAD.text = ""
        CIUDAD.Enabled = True
        ESTADO.text = ""
        ESTADO.Enabled = True
        TELF_HAB.text = ""
        TELF_HAB.Enabled = True
        TELF_TRAB.text = ""
        TELF_TRAB.Enabled = True
        MOVIL.text = ""
        MOVIL.Enabled = True
        E_MAIL.text = ""
        E_MAIL.Enabled = True
        accion = "nuevo"
    End Sub

    Private Sub E_MAILLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub CASATextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CASATextBox.TextChanged

    End Sub

    Private Sub CASALabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub CIUDADTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CIUDADTextBox.TextChanged

    End Sub

    Private Sub CIUDADLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ESTADOTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ESTADOTextBox.TextChanged

    End Sub

    Private Sub ESTADOLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TELF_HABTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TELF_HABTextBox.TextChanged

    End Sub

    Private Sub TELF_HABLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub TELF_TRABTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TELF_TRABTextBox.TextChanged

    End Sub

    Private Sub TELF_TRABLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub MOVILTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MOVILTextBox.TextChanged

    End Sub

    Private Sub MOVILLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub NÚMEROTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NÚMEROTextBox.TextChanged

    End Sub

    Private Sub NOMBRESTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOMBRESTextBox.TextChanged

    End Sub

    Private Sub APELLIDOSTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles APELLIDOSTextBox.TextChanged

    End Sub

    Private Sub PROFESIÓNTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PROFESIÓNTextBox.TextChanged

    End Sub

    Private Sub CÉDULATextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CÉDULATextBox.TextChanged

    End Sub

    Private Sub RESIDENCIATextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RESIDENCIATextBox.TextChanged

    End Sub

    Private Sub E_MAILTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles E_MAILTextBox.TextChanged

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        NÚMERO.Enabled = True
        NOMBRES.Enabled = True
        APELLIDOS.Enabled = True
        PROFESIÓN.Enabled = True
        CÉDULA.Enabled = True
        RESIDENCIA.Enabled = True
        CALLE.Enabled = True
        CASA.Enabled = True
        CIUDAD.Enabled = True
        ESTADO.Enabled = True
        TELF_HAB.Enabled = True
        TELF_TRAB.Enabled = True
        MOVIL.Enabled = True
        E_MAIL.Enabled = True
        accion = "editar"
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If accion = "nuevo" Then
            sql = "insert into Datos ( NÚMERO,NOMBRES,APELLIDOS,PROFESIÓN,CÉDULA,RESIDENCIA,CALLE,CASA,CIUDAD,ESTADO,TELF_HAB,MOVIL,E_MAIL )" _
                & "values ('" & NÚMERO.text & "' , '" & NOMBRES.text & "' , '" & APELLIDOS.text & "' , '" _
                & PROFESIÓN.text & "' ,'" & CÉDULA.text & "' , '" & RESIDENCIA.text & "' , '" _
                & CALLE.text & "' ,'" & CASA.text & "' , '" & CIUDAD.text & "' , '" & ESTADO.text & "' , '" _
                & TELF_HAB.text & "' , '" & TELF_TRAB & "' , '" & MOVIL.text & "' , '" & E_MAIL.text & "' )"
            conexion.Execute(Sql)
            MsgBox("El regitro se guardó correctamente")
        End If
        If accion = "editar" Then
            sql = "update Datos set NOMBRES='" & NOMBRES.text & "' , " _
                                & "APELLIDOS='" & APELLIDOS.text & "' , " _
                                & "PROFESIÓN='" & PROFESIÓN.text & "' , " _
                                & "CÉDULA='" & CÉDULA.text & "' , " _
                                & "RESIDENCIA='" & RESIDENCIA.text & "' , " _
                                & "CALLE='" & CALLE.text & "' , " _
                                & "CASA='" & CASA.text & "' , "
                                & "CIUDAD='" & CIUDAD.text & "' , " _
                                & "ESTADO='" & ESTADO.text & "' , " _
                                & "TELF_HAB='" & TELF_HAB & "' , " _
                                & "TELF_TRAB='" & TELF_TRAB & "' , " _
                                & "MOVIL='" & MOVIL.text & "' , " _
                                & "E_MAIL='" & E_MAIL.text & "' " _
                                & "where NÚMERO='" & NÚMERO.text & "'"
            Debug.Print(Sql)

            conexion.Execute(Sql)
            MsgBox("La edición del registro se realizó con éxito")
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim x As Integer
        x = MsgBox("En realidad desea eliminar el registro", MsgBoxStyle.YesNo)
        If x = vbYes Then
            sql = "delete from Datos where NÚMERO='" & NÚMERO.text & "'"
            conexion.Execute(Sql)
            MsgBox("Registro eliminado")
            NÚMERO.text = ""
            NOMBRES.text = ""
            APELLIDOS.text = ""
            PROFESIÓN.text = ""
            CÉDULA.text = ""
            RESIDENCIA.text = ""
            CALLE.text = ""
            CASA.text = ""
            CIUDAD.text = ""
            ESTADO.text = ""
            TELF_HAB.text = ""
            TELF_TRAB.text = ""
            MOVIL.text = ""
            E_MAIL.text = ""

        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim NÚMERO As String
        Dim rs As ADODB.Recordset

        NÚMERO = InputBox("Digite el Número de ASAPROVE")
        Sql = "Select * from Datos where NÚMERO='" & NÚMERO & "'"
        rs = conexion.Execute(Sql)

        If rs.BOF <> True Then
            rs.MoveFirst()
            NÚMERO.text = rs.Fields(0).Value
            NOMBRES.text = rs.Fields(1).Value
            APELLIDOS.text = rs.Fields(2).Value
            PROFESIÓN.text = rs.Fields(3).Value
            CÉDULA.text = rs.Fields(4).Value
            RESIDENCIA.text = rs.Fields(5).Value
            CALLE.text = rs.Fields(6).Value
            CASA.text = rs.Fields(7).Value
            CIUDAD.text = rs.Fields(8).Value
            ESTADO.text = rs.Fields(9).Value
            TELF_HAB.text = rs.Fields(10).Value
            TELF_TRAB.text = rs.Fields(11).Value
            MOVIL.text = rs.Fields(12).Value
            E_MAIL.text = rs.Fields(13).Value
        Else
            MsgBox("El regitro no existe")
        End If
    End Sub

End Class


 


25-Oct-2015 00:54
Nacho Cabanes (+83)

El código es largo, y es difícil de replicar porque es un fragmento de un programa cuya parte visual no podemos replicar. Por eso, ayudaría saber en qué línea obtienes el mensaje de error.


27-Oct-2015 03:28
Saulo David Jorgez

El error consiste en que, en la compilación me dice que no e ha declarado el nombre de la variables, tengo 92 errores. cuando trato de declarara con DIM, entonces me dice que txt no es un elemento que pertenece a string que es al tipo de variable a la que las declaro.  


30-Oct-2015 23:59
Nacho Cabanes (+83)

Pero esos errores te los marcará en líneas concretas. Al no poder rehacer el formulario, es difícil encontrar los errores si no se trata de errores terriblemente evidentes o das más detalles sobre las líneas concretas que se te quedan marcadas en color rojo.






(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)