1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Private Function GetDate(LaDate As String) As String
If Not (IsDate(LaDate)) Then
MsgBox "Entrée la date sous la forme jj/mm/aaaa"
GetDate = ""
Else
GetDate = Format(DateValue(LaDate), "dd/mm/yyyy")
End If
End Function
Private Sub ComboBox3_Change()
Sheets("Data").Range("C2").Value = ComboBox3.Value
Label1.Caption = Sheets("Data").Range("D2").Value
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub ListBox1_Click() ' au clic dans la ListBox1
For X = 1 To 4
Me.Controls("TextBox" & X).Value = Cells(Me.ListBox1.ListIndex + 2, X)
Next X
Me.Controls("Combobox3").Value = Cells(Me.ListBox1.ListIndex + 2, X + 1)
Me.Controls("TextBox5").Value = Cells(Me.ListBox1.ListIndex + 2, X + 2)
End Sub
Private Sub TextBox3_AfterUpdate()
TextBox3 = GetDate(TextBox3)
End Sub
Private Sub TextBox4_AfterUpdate()
TextBox4 = GetDate(TextBox4)
End Sub
Private Sub UserForm_INITIALIZE() 'à l'initialisation de l'UserForm
'remplissage de la ListBox1
Sheets("Room Reservation").Select
With ListBox1
.List = Range("reservation").Value
.ColumnCount = 7
.ColumnWidths = "100;100;50;50;50;50;200"
End With
End Sub
Private Sub CommandButton1_Click() 'bouton "modifier"
Application.ScreenUpdating = False
If MsgBox("Please confirm those modifications", vbYesNo, "Confirmation") = vbNo Then
Exit Sub
Else
For X = 1 To 4
With ListBox1
Cells(.ListIndex + 2, X) = Me.Controls("TextBox" & X).Text 'On écrit dans chaque colonne les valeurs des différents controls
End With
Next X
With ListBox1
Cells(Me.ListBox1.ListIndex + 2, X + 1) = Me.Controls("Combobox3").Value
Cells(Me.ListBox1.ListIndex + 2, X + 2) = Me.Controls("TextBox5").Value
End With
End If
Application.ScreenUpdating = True
Unload Me 'vide et ferme l'UserForm
End Sub |
Partager