Ciberseguridad y Seguridad Informática Franco Correa Grupo B.pptx
Option explicit
1. OptionExplicit
DimArchivoIMG AsString
Private Subcmd_Agregar_Click()
Dim i As Integer
If cbo_Nombre.Text="" Then
MsgBox "Nombre inválido",vbInformation+vbOKOnly
cbo_Nombre.SetFocus
ExitSub
End If
If Not(Mid(cbo_Nombre.Text,1,1) Like "[a-z]"OrMid(cbo_Nombre.Text,1,1) Like "[A-Z]")
Then
MsgBox "Nombre inválido",vbInformation+vbOKOnly
cbo_Nombre.SetFocus
ExitSub
End If
For i = 2 To Len(cbo_Nombre.Text)
If Mid(cbo_Nombre.Text,i,1) Like "#"Then
MsgBox "Nombre inválido",vbInformation+vbOKOnly
cbo_Nombre.SetFocus
ExitSub
EndIf
Next
2. Sheets("Clientes").Activate
Dim fClienteAs Integer
fCliente =nCliente(cbo_Nombre.Text)
If fCliente=0 Then
Do While NotIsEmpty(ActiveCell)
ActiveCell.Offset(1,0).Activate 'si el registronoexiste,se vaal final.
Loop
Else
Cells(fCliente,1).Select 'cuando ya existe el registro,cumple estacondición.
End If
'Aqui escuando agregamoso modificamosel registro
Application.ScreenUpdating=False
ActiveCell=cbo_Nombre
ActiveCell.Offset(0,1) = txt_Direccion
ActiveCell.Offset(0,2) = txt_Telefono
ActiveCell.Offset(0,3) = txt_ID
ActiveCell.Offset(0,4) = txt_Email
ActiveCell.Offset(0,5) = ArchivoIMG
4. MsgBox "Cliente eliminado",vbInformation+vbOKOnly
cbo_Nombre.SetFocus
End If
End Sub
Private Subcmd_Cerrar_Click()
End
End Sub
Private Subcbo_Nombre_Change()
On Error Resume Next
If nCliente(cbo_Nombre.Text) <>0 Then
Sheets("Clientes").Activate
Cells(cbo_Nombre.ListIndex +2, 1).Select
txt_Direccion=ActiveCell.Offset(0,1)
txt_Telefono=ActiveCell.Offset(0,2)
txt_ID= ActiveCell.Offset(0,3)
txt_Email = ActiveCell.Offset(0,4)
fotografia.Picture =LoadPicture("")
fotografia.Picture =LoadPicture(ActiveCell.Offset(0,5))
5. ArchivoIMG= ActiveCell.Offset(0,5)
Else
txt_Direccion=""
txt_Telefono=""
txt_ID= ""
txt_Email = ""
ArchivoIMG= ""
fotografia.Picture =LoadPicture("")
End If
End Sub
Private Subcbo_Nombre_Enter()
CargarLista
End Sub
SubCargarLista()
cbo_Nombre.Clear
Sheets("Clientes").Select
Range("A2").Select
Do While NotIsEmpty(ActiveCell)
cbo_Nombre.AddItemActiveCell.Value
ActiveCell.Offset(1,0).Select
Loop
End Sub
6. SubLimpiarFormulario()
CargarLista
cbo_Nombre = ""
txt_Direccion= ""
txt_Telefono=""
txt_ID = ""
txt_Email = ""
ArchivoIMG= ""
End Sub
Private Subcmd_Imagen_Click()
On Error Resume Next
ArchivoIMG= Application.GetOpenFilename("Imágenesjpg,*.jpg,Imágenesbmp,*.bmp",0,
"SeleccionarImágenparaReegistrode Clientes")
fotografia.Picture =LoadPicture("")
fotografia.Picture =LoadPicture(ArchivoIMG)
End Sub