codigo 1 parque de vehiculos
modulo 1
Private Sub CommandButton1_Click()
'registrar
Dim celda As Object
Dim rango As Range
Dim xfila As Integer
Dim fecha As Date
Dim hora As Date
Sheets("registro").Select
fecha = Date
hora = Time
Range("a1").Activate
TextBox1.SetFocus
xfila = ActiveCell.CurrentRegion.Rows.Count
ActiveCell.Offset(xfila, 0) = Date
ActiveCell.Offset(xfila, 1) = hora
ActiveCell.Offset(xfila, 2) = TextBox1.Text
ActiveCell.Offset(xfila, 3) = ComboBox1.Text
ActiveCell.Offset(xfila, 7) = "ocupado"
Set rango = Range("h2:h41")
For Each celda In rango
If celda = "ocupado" Then
celda.Interior.ColorIndex = 3
End If
If celda = "" Then
celda.Interior.ColorIndex = 0
End If
Next celda
TextBox1.Text = ""
ComboBox1.Text = ""
End Sub
Private Sub CommandButton2_Click()
'salida de carros
Dim celda As Object
Dim rango As Range
Dim x As String
Dim encontrado As Boolean
Dim xfila As Integer
Dim fecha As Date
Dim hora As Date
Sheets("registro").Select
fecha = Date
hora = Time
x = CStr(TextBox1.Text)
encontrado = False
Range("c1").Select
Do Until IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value Like x Then
encotrado = True
Exit Do
End If
Loop
ActiveCell.Offset(0, 2).Value = Date
ActiveCell.Offset(0, 3).Value = hora
ActiveCell.Offset(0, 5).Value = "libre"
Set rango = Range("h2:h41")
For Each celda In rango
If celda = "libre" Then
celda.Interior.ColorIndex = 4
End If
If celda = "" Then
celda.Interior.ColorIndex = 0
End If
Next celda
ActiveCell.Offset(xfila, 7) = "libre"
TextBox1.Text = ""
End Sub
modulo 2 contrasena password
Private Sub workbook_pen()
Application.Visible = False
UserForm2.Show
End Sub
Private Sub CommandButton1_Click()
If Trim(TextBox1.Text) = "" Then
MsgBox "ingrese usuario"
End If
If Trim(TextBox2.Text) = "" Then
MsgBox "ingrese contrasena"
End If
If Trim(TextBox1.Text) = "admi" And Trim(TextBox2.Text) = "admi" Then
MsgBox "acceso permitido", vbInformation, "ok"
Application.Visible = True
End
'UserForm1.Show
Else
MsgBox "datos incorrectos"
End If
End Sub
thisworkbook
Private Sub Workbook_Open()
Application.Visible = False
UserForm2.Show
End Sub