0% found this document useful (0 votes)
14 views22 pages

Modulo de Programación

The document contains a series of VBA (Visual Basic for Applications) subroutines for managing a user interface related to inventory management. It includes functionalities for registering, modifying, and searching for equipment records, as well as handling user interactions such as mouse movements and button clicks. The code ensures that all required fields are filled before allowing the user to create or modify records in an Excel sheet named 'Inventario'.

Uploaded by

Andres Fuentes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views22 pages

Modulo de Programación

The document contains a series of VBA (Visual Basic for Applications) subroutines for managing a user interface related to inventory management. It includes functionalities for registering, modifying, and searching for equipment records, as well as handling user interactions such as mouse movements and button clicks. The code ensures that all required fields are filled before allowing the user to create or modify records in an Excel sheet named 'Inventario'.

Uploaded by

Andres Fuentes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Menu de inicio:

Private Sub Configuraciones_Click()

[Link] = True

Unload Me

End Sub

Private Sub Registro_Click()

Call CallRegistro

End Sub

Private Sub Inventario_Click()

Call CallInventario

End Sub

Private Sub Salir_Click()

Unload Me

End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As


Single, ByVal Y As Single)

[Link] = False

[Link] = False

[Link] = False

[Link] = False

End Sub

Private Sub Registro_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)

[Link] = True

[Link] = False

[Link] = False

[Link] = False

End Sub
Private Sub Inventario_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As
Single, ByVal Y As Single)

[Link] = False

[Link] = True

[Link] = False

[Link] = False

End Sub

Private Sub Configuraciones_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X


As Single, ByVal Y As Single)

[Link] = False

[Link] = False

[Link] = True

[Link] = False

End Sub

Private Sub Salir_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single,
ByVal Y As Single)

[Link] = False

[Link] = False

[Link] = False

[Link] = True

End Sub

Modificar:

Private Sub CmdCerrarModificar_Click()

Unload Me

End Sub

Private Sub CmdBuscarRegistro_Click()

Dim UltimaFila As Variant


Dim FILADOC As Variant

UltimaFila = Sheets("Inventario").Range("B" & [Link]).End(xlUp).Row

For FILADOC = 3 To UltimaFila

If Sheets("Inventario").Range("B" & FILADOC).Value Like [Link] Then

[Link] = Sheets("Inventario").Range("C" & FILADOC)

[Link] = Sheets("Inventario").Range("D" & FILADOC)

[Link] = Sheets("Inventario").Range("E" & FILADOC)

[Link] = Sheets("Inventario").Range("F" & FILADOC)

[Link] = Sheets("Inventario").Range("G" & FILADOC)

[Link] = Sheets("Inventario").Range("H" & FILADOC)

[Link] = Sheets("Inventario").Range("I" & FILADOC)

[Link] = Sheets("Inventario").Range("J" & FILADOC)

[Link] = Sheets("Inventario").Range("K" & FILADOC)

[Link] = Sheets("Inventario").Range("L" & FILADOC)

[Link] = Sheets("Inventario").Range("M" & FILADOC)

[Link] = Sheets("Inventario").Range("N" & FILADOC)

[Link] = Sheets("Inventario").Range("O" & FILADOC)

[Link] = Sheets("Inventario").Range("P" & FILADOC)

[Link] = Sheets("Inventario").Range("Q" & FILADOC)

[Link] = Sheets("Inventario").Range("R" & FILADOC)

[Link] = Sheets("Inventario").Range("S" & FILADOC)

[Link] = Sheets("Inventario").Range("T" & FILADOC)

[Link] = Sheets("Inventario").Range("U" & FILADOC)

[Link] = Sheets("Inventario").Range("V" & FILADOC)

[Link] = Sheets("Inventario").Range("W" & FILADOC)


[Link] = Sheets("Inventario").Range("X" & FILADOC)

End If

Next FILADOC

End Sub

Private Sub CmdModificarRegistro_Click()

Dim Fila As Variant

Dim Linea As Variant

Dim ValorBuscado As Variant

ValorBuscado = [Link]

Set Fila = [Link]("Inventario").Range("B:B").Find(ValorBuscado, lookAt:=xlWhole)

Linea = [Link]

[Link]("Inventario").Range("C" & Linea).Value = Me.TxtCoordinacion2

[Link]("Inventario").Range("D" & Linea).Value = Me.TxtTipoEquipo2

[Link]("Inventario").Range("E" & Linea).Value = Me.TxtProcesador2

[Link]("Inventario").Range("F" & Linea).Value = Me.TxtMemoriaRAM2

[Link]("Inventario").Range("G" & Linea).Value = Me.TxtDiscoDuro2

[Link]("Inventario").Range("H" & Linea).Value = Me.TxtFuentePoder2

[Link]("Inventario").Range("I" & Linea).Value = Me.TxtSistemaOperativo2

[Link]("Inventario").Range("J" & Linea).Value = Me.TxtCbSeEquipo2

[Link]("Inventario").Range("K" & Linea).Value = Me.TxtMonitor2

[Link]("Inventario").Range("L" & Linea).Value = Me.TxtCbSeMonitor2


[Link]("Inventario").Range("M" & Linea).Value = Me.TxtTeclado2

[Link]("Inventario").Range("N" & Linea).Value = Me.TxtCbSeTeclado2

[Link]("Inventario").Range("O" & Linea).Value = Me.TxtRaton2

[Link]("Inventario").Range("P" & Linea).Value = Me.TxtCbSeRaton2

[Link]("Inventario").Range("Q" & Linea).Value = Me.TxtCornetas2

[Link]("Inventario").Range("R" & Linea).Value = Me.TxtCbSeCornetas2

[Link]("Inventario").Range("S" & Linea).Value = Me.TxtImpresora2

[Link]("Inventario").Range("T" & Linea).Value = Me.TxtCbSeImpresora2

[Link]("Inventario").Range("U" & Linea).Value = Me.TxtWifi2

[Link]("Inventario").Range("V" & Linea).Value = Me.TxtCbSeWifi2

[Link]("Inventario").Range("W" & Linea).Value = Me.TxtSwitch2

[Link]("Inventario").Range("X" & Linea).Value = Me.TxtCbSeSwitch2

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty
[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link]

MsgBox "Modificacion Exitosa"

End Sub

Private Sub UserForm_Click()

End Sub

Registro:

Option Explicit

Private Sub CmdCerrarRegistro_Click()

Unload Me

End Sub

Private Sub CmdCrearRegistro_Click()

Dim UltimaFila As Variant

Dim Repetido As Variant


If TxtCodigo = Empty And TxtCoordinacion = Empty And TxtTipoEquipo = Empty And TxtProcesador
= Empty And TxtMemoriaRAM = Empty And TxtDiscoDuro = Empty And TxtFuentePoder = Empty
And TxtSistemaOperativo = Empty And TxtCbSeEquipo = Empty And TxtMonitor = Empty And
TxtCbSeMonitor = Empty And TxtTeclado = Empty And TxtCbSeTeclado = Empty And TxtRaton =
Empty And TxtCbSeRaton = Empty And TxtImpresora = Empty And TxtCbSeImpresora = Empty And
TxtCorneta = Empty And TxtCbSeCorneta = Empty And TxtWifi = Empty And TxtCbSeWifi = Empty
And TxtSwitch = Empty And TxtCbSeSwitch = Empty Then

MsgBox "Para Registrar Completa Todos los Campos.", vbCritical, "Campos Vacios !!"

Exit Sub

End If

If TxtCodigo = Empty Then

MsgBox "Por Favor, Complete El Campo Codigo.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCoordinacion = Empty Then

MsgBox "Por Favor, Complete El Campo Coordinación.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtTipoEquipo = Empty Then

MsgBox "Por Favor, Complete El Campo Tipo de Equipo.", vbExclamation, "Campos Vacios !"

Exit Sub

End If
If TxtProcesador = Empty Then

MsgBox "Por Favor, Complete El Campo Procesador.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtMemoriaRAM = Empty Then

MsgBox "Por Favor, Complete El Campo Memoria RAM.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtDiscoDuro = Empty Then

MsgBox "Por Favor, Complete El Campo Disco Duro.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtFuentePoder = Empty Then

MsgBox "Por Favor, Complete El Campo Fuente de Poder.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtSistemaOperativo = Empty Then

MsgBox "Por Favor, Complete El Campo Sistema Operativo.", vbExclamation, "Campos Vacios !"

Exit Sub

End If
If TxtCbSeEquipo = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Equipo.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtMonitor = Empty Then

MsgBox "Por Favor, Complete El Campo Monitor.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeMonitor = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Monitor.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtTeclado = Empty Then

MsgBox "Por Favor, Complete El Campo Teclado.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeTeclado = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Teclado.", vbExclamation, "Campos Vacios !"

Exit Sub
End If

If TxtRaton = Empty Then

MsgBox "Por Favor, Complete El Campo Raton.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeRaton = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Raton.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtImpresora = Empty Then

MsgBox "Por Favor, Complete El Campo Impresora.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeImpresora = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Impresora.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCorneta = Empty Then

MsgBox "Por Favor, Complete El Campo Cornetas.", vbExclamation, "Campos Vacios !"
Exit Sub

End If

If TxtCbSeCorneta = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Cornetas.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtWifi = Empty Then

MsgBox "Por Favor, Complete El Campo Wifi.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeWifi = Empty Then

MsgBox "Por Favor, Complete El Campo CB/SE - Wifi.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtSwitch = Empty Then

MsgBox "Por Favor, Complete El Campo Switch.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

If TxtCbSeSwitch = Empty Then


MsgBox "Por Favor, Complete El Campo CB/SE - Switch.", vbExclamation, "Campos Vacios !"

Exit Sub

End If

Repetido = [Link](Sheets("Inventario").Range("B:B"), [Link])

If Repetido = 1 Then

MsgBox "El Codigo Ya Existe"

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty
[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

Else

UltimaFila = Sheets("Inventario").Range("B" & [Link]).End(xlUp).Row + 1

Sheets("Inventario").Range("B" & UltimaFila) = [Link]

Sheets("Inventario").Range("C" & UltimaFila) = [Link]

Sheets("Inventario").Range("D" & UltimaFila) = [Link]

Sheets("Inventario").Range("E" & UltimaFila) = [Link]

Sheets("Inventario").Range("F" & UltimaFila) = [Link]

Sheets("Inventario").Range("G" & UltimaFila) = [Link]

Sheets("Inventario").Range("H" & UltimaFila) = [Link]

Sheets("Inventario").Range("I" & UltimaFila) = [Link]

Sheets("Inventario").Range("J" & UltimaFila) = [Link]

Sheets("Inventario").Range("K" & UltimaFila) = [Link]

Sheets("Inventario").Range("L" & UltimaFila) = [Link]

Sheets("Inventario").Range("M" & UltimaFila) = [Link]

Sheets("Inventario").Range("N" & UltimaFila) = [Link]

Sheets("Inventario").Range("O" & UltimaFila) = [Link]

Sheets("Inventario").Range("P" & UltimaFila) = [Link]

Sheets("Inventario").Range("Q" & UltimaFila) = [Link]

Sheets("Inventario").Range("R" & UltimaFila) = [Link]

Sheets("Inventario").Range("S" & UltimaFila) = [Link]

Sheets("Inventario").Range("T" & UltimaFila) = [Link]


Sheets("Inventario").Range("U" & UltimaFila) = [Link]

Sheets("Inventario").Range("V" & UltimaFila) = [Link]

Sheets("Inventario").Range("W" & UltimaFila) = [Link]

Sheets("Inventario").Range("X" & UltimaFila) = [Link]

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty

[Link] = Empty
End If

[Link]

MsgBox "Registro Exitoso"

End Sub

Private Sub UserForm_Click()

End Sub

Inventario:

Private Sub CmdCerrarInventario_Click()

Unload Me

End Sub

Private Sub LstCaracteristica_DblClick(ByVal Cancel As [Link])

Dim X As Long

With [Link]

X = .ListIndex

[Link] = .List(X, 0)

End With

[Link]

End Sub
Private Sub rdbCodigos_Click()

Call [Link]

End Sub

Private Sub rdbCoordinacion_Click()

Call [Link]

End Sub

Private Sub TxtRegistro_Change()

Call [Link]

End Sub

Private Sub UserForm_Initialize()

Call MiModulo.CagarLista_Caracteristica

Call MiModulo.CagarLista_Perifericos

Call MiModulo.CagarLista_Interruptor

End Sub

Private Sub UserForm_Terminate()

Call [Link]

End Sub

Modulo:

Sub CallRegistro()

[Link]

End Sub

Sub CallInventario()
Load Inventario

[Link] = True

[Link]

End Sub

Sub QuitarFiltros()

[Link] = False

[Link]("InventarioTecnologico").ShowAutoFilter = False

[Link]("InventarioTecnologico").ShowAutoFilter = True

[Link] = True

End Sub

Sub CagarLista_Caracteristica()

On Error GoTo Depurar

With [Link]

.Clear

.ColumnCount = 9

.ColumnHeads = True

.ColumnWidths = "60pt;230pt;270pt;100pt;200pt;200pt;200pt;170pt;170pt"

Dim Fila As Range, FilasFiltro As Range

Set FilasFiltro =
[Link]("InventarioTecnologico").[Link](xlCellTypeVisible).Rows

For Each Fila In FilasFiltro

.AddItem

.List(.ListCount - 1, 0) = [Link](1).Value

.List(.ListCount - 1, 1) = [Link](2).Value

.List(.ListCount - 1, 2) = [Link](3).Value

.List(.ListCount - 1, 3) = [Link](4).Value
.List(.ListCount - 1, 4) = [Link](5).Value

.List(.ListCount - 1, 5) = [Link](6).Value

.List(.ListCount - 1, 6) = [Link](7).Value

.List(.ListCount - 1, 7) = [Link](8).Value

.List(.ListCount - 1, 8) = [Link](9).Value

Next Fila

End With

On Error GoTo 0

Exit Sub

Depurar:

[Link] "No Data"

On Error GoTo 0

End Sub

Sub CagarLista_Perifericos()

On Error GoTo Depurar

With [Link]

.Clear

.ColumnCount = 10

.ColumnHeads = True

.ColumnWidths = "130pt;100pt;130;100;130pt;100pt;85pt;100pt;60pt;100pt"

Dim Fila As Range, FilasFiltro As Range

Set FilasFiltro =
[Link]("InventarioTecnologico").[Link](xlCellTypeVisible).Rows
For Each Fila In FilasFiltro

.AddItem

.List(.ListCount - 1, 0) = [Link](10).Value

.List(.ListCount - 1, 1) = [Link](11).Value

.List(.ListCount - 1, 2) = [Link](12).Value

.List(.ListCount - 1, 3) = [Link](13).Value

.List(.ListCount - 1, 4) = [Link](14).Value

.List(.ListCount - 1, 5) = [Link](15).Value

.List(.ListCount - 1, 6) = [Link](16).Value

.List(.ListCount - 1, 7) = [Link](17).Value

.List(.ListCount - 1, 8) = [Link](18).Value

.List(.ListCount - 1, 9) = [Link](19).Value

Next Fila

End With

On Error GoTo 0

Exit Sub

Depurar:

[Link] "No Data"

On Error GoTo 0

End Sub

Sub CagarLista_Interruptor()

On Error GoTo Depurar

With [Link]
.Clear

.ColumnCount = 4

.ColumnHeads = True

.ColumnWidths = "130pt;100pt;130pt;100pt"

Dim Fila As Range, FilasFiltro As Range

Set FilasFiltro =
[Link]("InventarioTecnologico").[Link](xlCellTypeVisible).Rows

For Each Fila In FilasFiltro

.AddItem

.List(.ListCount - 1, 0) = [Link](20).Value

.List(.ListCount - 1, 1) = [Link](21).Value

.List(.ListCount - 1, 2) = [Link](22).Value

.List(.ListCount - 1, 3) = [Link](23).Value

Next Fila

End With

On Error GoTo 0

Exit Sub

Depurar:

[Link] "No Data"

On Error GoTo 0

End Sub

Sub RealizarFiltro()

Dim criterio As String


criterio = "*" & [Link] & "*"

If [Link] = True Then

[Link]("InventarioTecnologico").[Link] Field:=2, Criteria1:=criterio

ElseIf [Link] = True Then

[Link]("InventarioTecnologico").[Link] Field:=1, Criteria1:=criterio

End If

Call MiModulo.CagarLista_Caracteristica

Call MiModulo.CagarLista_Perifericos

Call MiModulo.CagarLista_Interruptor

End Sub

Sub ResetearLista()

Call [Link]

Call MiModulo.CagarLista_Caracteristica

Call MiModulo.CagarLista_Perifericos

Call MiModulo.CagarLista_Interruptor

[Link] = ""

[Link]

End Sub

Sub OcultarExcel()

[Link] = False

[Link]

End Sub
Sub Formulario()

[Link]

End Sub

You might also like