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
| Sub ajout_capteurs(ByVal Nom As String, nbr_capteurs As Integer)
'----------------------------------------------------------------------------------------------------------------------------------------------------'
'UNE FONCTION QUI CREE UN NOUV BOUTT TYPE COMBOBOX ET LE REMPLIT'
'----------------------------------------------------------------------------------------------------------------------------------------------------'
pos_init_x = 96
pos_init_y = 318
hauteur_init = 25
longueur_init = 90
'ajout d'une combobox'
Set nouv_capteur = Form_dates.Controls.Add("Forms.Combobox.1")
nouv_capteur.Name = Nom
MsgBox nouv_capteur.Name
'---------POSITIONNEMENT ET NOMINATION DU NOUVEAU BOUTTON DE CAPTEUR (saut à la ligne tous les 4 capteurs)--------'
nouv_capteur.Width = longueur_init
nouv_capteur.Height = hauteur_init
If nbr_capteurs <= 3 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs) + 10 * nbr_capteurs
nouv_capteur.Top = pos_init_y
ElseIf nbr_capteurs < 8 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs - 4) + 10 * (nbr_capteurs - 4)
nouv_capteur.Top = pos_init_y + hauteur_init + 10
ElseIf nbr_capteurs <= 11 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs - 8) + 10 * (nbr_capteurs - 8)
nouv_capteur.Top = pos_init_y + hauteur_init * 2 + 10 * 2
Else
MsgBox "Une erreur c'est produite. Vous êtes limité à 12 capteurs. Merci de RESET et de recommencer"
Unload Me
End If
'--------CREATION DE LA BONNE TAILLE DE TABLEAU EN FCT DU NOMBRE DE PAGE DE DATASn-------'
With Sheets("DATAS1")
Set Plage1 = .Range("S3:S" & .Range("S1048576").End(xlUp).Row)
End With
If Feuille_Existe("DATAS2") Then
With Sheets("DATAS2")
Set Plage2 = .Range("S3:S" & .Range("S1048576").End(xlUp).Row)
End With
ReDim Tab_capt(1 To Plage1.Count + Plage2.Count)
Else
ReDim Tab_capt(1 To Plage1.Count)
End If
Sheets("DATAS1").Select
For Each cell In Plage1
i = i + 1
Tab_capt(i) = cell
Next
'--------REMPLISSAGE DU NOUVEAU BOUTON CAPTEUR-------'
If Feuille_Existe("DATAS2") Then
Sheets("DATAS2").Select
j = i
For Each cell In Plage2
j = j + 1
Tab_capt(j) = cell
Next
End If
nouv_capteur.List = Tab_capt
nouv_capteur.Change
End Sub |
Partager