Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Private Sub BT

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Private Sub BT_AGREGAR_Click()

Range("B4").EntireRow.Insert

Range("B4").Value = Me.txt_codigo.Value

Range("C4").Value = Me.txt_nombre.Value

Range("D4").Value = Me.txt_apellido.Value

Range("E4").Value = Me.txt_sexo.Value

Range("F4").Value = Me.txt_edad.Value

txt_codigo.Value = Range("B2").Value

Me.txt_nombre.Value = Empty

Me.txt_apellido.Value = Empty

Me.txt_sexo.Value = Empty

Me.txt_edad.Value = Empty

Private Sub BT_LIMPIAR_Click()

Miformulario.Height=395

Me.txt_nombre.Value = Empty

Me.txt_apellido.Value = Empty

Me.txt_sexo.Value = Empty

Me.txt_edad.Value = Empty

End Sub

Private Sub BT_EDITAR_Click()

If LISTA.ListIndex = -1 Then

MsgBox ("seleccione un registro")

Else
miformulario.Height = 395

Me.BT_AGREGAR.Enabled = False

Me.BT_MODIFICAR.Enabled = True

End If

End Sub

Private Sub BT_ELIMINAR_Click()

Valor_buscado = txt_codigo.Value

Datos = txt_nombre.Value & “” & txt_apellido.Value

' On error resume next

If Lista.ListIndex = -1 Then

MsgBox (“seleccione un registro”)

Else

Respuesta = Application.InputBox(“desea eliminar al registro: & datos, “ingrese clave”)

If respuesta = “123” Then

' Set fila = Sheets(*BD*).Range(“B:D”).Find(valor_buscando, lookat:”x)

' Línea = fila.Row

' Range("B1" & linea).EntireRow.Delete

End if

End Sub

Private Sub BT_MODIFICAR_Click()

Dim fila As Object

Dim linea As Integer

valor_buscando = Me.txt_codigo
Set fila = Sheets("BD").Range("B:B").Find(valor_buscando, lookat:=xlWhole)

linea = fila.Row

Range("C" & linea).Value = Me.txt_nombre.Value

Range("D" & linea).Value = Me.txt_apellido.Value

Range("E" & linea).Value = Me.txt_sexo.Value

Range("F" & linea).Value = Me.txt_edad.Value

End Sub

Private Sub BT_REGISTRAR_Click()

miformulario.Height = 395

Me.BT_MODIFICAR.Enabled = False

Me.txt_codigo.Value=Rango(“B2”).Value

Me.BT_AGREGAR.Enabled=true

' Limpa TxtBox

Me.txt_nombre.Value = Empty

Me.txt_apellido.Value = Empty

Me.txt_sexo.Value = Empty

Me.txt_edad.Value = Empty
End Sub

Private Sub LISTA_Click()

Dim codigo As Integer

codigo = LISTA.List(LISTA.ListIndex, 0)

Me.txt_codigo.Value = código

Me.BT_AGREGAR.Enabled = False

Me.BT_MODIFICAR.Enabled = True

End Sub

Private Sub txt_codigo_Change()

Dim codigo As Integer

codigo = txt_codigo.Value

Me.txt_nombre = Application.WorksheetFunction.VLookup(codigo, Sheets("BD").Range("B:F"),


2, 0)

Me.txt_apellido = Application.WorksheetFunction.VLookup(codigo, Sheets("BD").Range("B:F"),


3, 0)

Me.txt_sexo = Application.WorksheetFunction.VLookup(codigo, Sheets("BD").Range("B:F"), 4,


0)

Me.txt_edad = Application.WorksheetFunction.VLookup(codigo, Sheets("BD").Range("B:F"), 5,


0)
End Sub

Private Sub UserForm_Activate()

Me.LISTA.RowSource = "CLIENTES"

Me.LISTA.ColumnCount = 5

miformulario.Height = 200

End Sub

Private Sub BT_BUSQUEDA_Click()

numerodedatos = hoja1.Range(“B” & Rows.Count).End(xlUp).Rows)

Lista = Clear

Lista.RowsRoucer

MsgBox(munerodedatos)

End Sub

You might also like