| Deutsch English Français Italiano |
|
<vn666t$3itm$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Laika <nestorlambda@not-for-mail.invalid>
Newsgroups: fr.comp.sys.mac.programmation
Subject: =?UTF-8?B?UmU6IEdlc3Rpb24gZGVzIENyw6lkaXRzIDEuOC4wIChGaW5hbGUp?=
Date: Sun, 26 Jan 2025 21:33:33 +0100
Organization: A noiseless patient Spider
Lines: 260
Message-ID: <vn666t$3itm$2@dont-email.me>
References: <4a96c3c37dfc90e74f15e34cbc73a3a201c8af2b@i2pn2.org>
<92683406cfd09d93b3ffba301bad013218eac1d9@i2pn2.org>
<vn2qnb$2qu38$5@dont-email.me> <6796583c$0$16846$426a74cc@news.free.fr>
<9f641bb4a515a61de9a9097ff6d178a5e5c1fafe@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 26 Jan 2025 21:33:33 +0100 (CET)
Injection-Info: dont-email.me; posting-host="45b64ccc70aebf3d38fad1b7be424ac3";
logging-data="117686"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX190TyAfIlmyuYmuAAvFt/hQL+g+1hP0Cqg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:LadJT/lhKHrq7FcG357uskEKKnY=
In-Reply-To: <9f641bb4a515a61de9a9097ff6d178a5e5c1fafe@i2pn2.org>
Content-Language: fr, fr-BE
Bytes: 11009
Le 26/01/25 à 16:56, Prime a écrit :
ok j'ai vérifié ton programme c'est pas mal, mais le contrôle des
entrées est faible comme par exemple pour les dates, et quelques
fonctions redondantes pourraient ralentir l'ensemble en cas de gros
volume, alors voici mon corrigé:
Points d'optimisation appliqués :
Réduction des appels redondants : Les appels à des fonctions comme
Window1.AutoProchaineOpération sont effectués une seule fois et stockés
dans des variables.
Réduction des manipulations inutiles de texte : Les conversions de texte
et valeurs numériques sont effectuées une fois et réutilisées.
Réduction des boucles inutiles : La mise à jour des alignements des
cellules est effectuée une seule fois après les modifications dans ListBox1.
Réduction des opérations sur l'interface utilisateur : Les mises à jour
de l'interface sont centralisées et les champs sont réinitialisés en une
seule fonction EnableInputs.
// On commence par réécrire la section où nous ajoutons un automatisme
If me.Caption = "Ajouter Cette Automatisme" Then
// Initialiser les variables
Dim dateetheurecell As Date
dateetheurecell = New Date
// Charger les valeurs des TextFields
Dim year As Integer = Val(TextField3.Text)
Dim month As Integer = Val(TextField2.Text)
Dim day As Integer = Val(TextField1.Text)
Dim hour As Integer = Val(TextField4.Text)
Dim minute As Integer = Val(TextField5.Text)
Dim second As Integer = Val(TextField6.Text)
// Définir la date et l'heure
dateetheurecell.Year = year
dateetheurecell.Month = month
dateetheurecell.Day = day
dateetheurecell.Hour = hour
dateetheurecell.Minute = minute
dateetheurecell.Second = second
// Ajouter une ligne dans la ListBox
ListBox1.AddRow
Dim dateStr As String = Str(dateetheurecell.TotalSeconds,
"00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 0) = dateStr
// Mettre à jour la cellule de la date/heure abrégée
Dim dateAbbr As String = NomJourAbrégé(dateetheurecell) + " " +
dateetheurecell.AbbreviatedDate + " - " + dateetheurecell.LongTime
ListBox1.Cell(ListBox1.LastRowIndex, 1) = dateAbbr
// Afficher la fenêtre de génération
GénérerUnePremiereOpérationDateDeDebut.Visible = True
GénérerUnePremiereOpérationDateDeDebut.ShowModal
If ValeurGénérerUnePremiereOpérationDateDeDebut = "OUI" Then
ListBox1.Cell(ListBox1.LastRowIndex, 2) = Str(dateetheurecell,
"00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 3) = dateAbbr
Else
Dim nextOp As Date =
Window1.AutoProchaineOpération(dateetheurecell, Val(TextField8.Text),
PopupMenu1.SelectedRowIndex)
ListBox1.Cell(ListBox1.LastRowIndex, 2) = Str(nextOp.TotalSeconds,
"00000000000000000000000")
ListBox1.Cell(ListBox1.LastRowIndex, 3) = NomJourAbrégé(nextOp) + "
" + nextOp.AbbreviatedDate + " - " + nextOp.LongTime
End If
' Mise à jour du champ TextField7 avec une conversion de format
TextField7.Text = Str(Val(TextField7.Text.Replace(",", ".")), "-#0.00")
ListBox1.Cell(ListBox1.LastRowIndex, 4) = Str(Val(TextField7.Text),
"-#0.00")
' Mise à jour du statut de la case à cocher et du bouton radio
ListBox1.Cell(ListBox1.LastRowIndex, 5) = If(RadioButton1.Value, "X", "")
ListBox1.Cell(ListBox1.LastRowIndex, 6) = Str(Val(TextField8.Text), "0")
ListBox1.Cell(ListBox1.LastRowIndex, 7) =
Str(PopupMenu1.SelectedRowIndex)
If CheckBox1.Value Then
ListBox1.Cell(ListBox1.LastRowIndex, 8) = "Suspendre"
ListBox1.Cell(ListBox1.LastRowIndex, 3) = "Suspendu"
Else
ListBox1.Cell(ListBox1.LastRowIndex, 8) = ""
End If
// Appel à la fonction TousLes
ListBox1.Cell(ListBox1.LastRowIndex, 9) =
TousLes(Val(ListBox1.Cell(ListBox1.LastRowIndex, 6)),
Val(ListBox1.Cell(ListBox1.LastRowIndex, 7)))
// Réinitialisation des champs de saisie
TextField3.Text = ""
TextField2.Text = ""
TextField1.Text = ""
TextField4.Text = ""
TextField5.Text = ""
TextField6.Text = ""
// Réinitialisation de l'interface
EnableInputs(True)
' Mise à jour de l'alignement des cellules
For i As Integer = 0 To ListBox1.RowCount - 1
ListBox1.CellAlignmentAt(i, 1) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 3) = ListBox.Alignments.Center
ListBox1.CellAlignmentAt(i, 4) = ListBox.Alignments.Right
Next
End If
// Réécriture pour la modification d'un automatisme
If me.Caption = "Modifier Cette Automatisme" Then
Dim dateetheurecell As Date
dateetheurecell = New Date
// Récupération des valeurs de la date et de l'heure
dateetheurecell.Year = Val(TextField3.Text)
dateetheurecell.Month = Val(TextField2.Text)
dateetheurecell.Day = Val(TextField1.Text)
dateetheurecell.Hour = Val(TextField4.Text)
dateetheurecell.Minute = Val(TextField5.Text)
dateetheurecell.Second = Val(TextField6.Text)
Dim SautePeriode As Boolean = False
// Vérification de l'état de la case à cocher
If CheckBox1.Value = False And
ListBox1.Cell(ListBox1.SelectedRowIndex, 8) = "Suspendre" Then
SautePeriode = True
SautePeriodeAuto.Visible = True
SautePeriodeAuto.ShowModal
Dim DateCourente As Date = New Date
Dim DateAVérifier As Date
DateAVérifier.TotalSeconds =
Val(ListBox1.Cell(ListBox1.SelectedRowIndex, 2))
If SauteChangementPeriodeAuto = "Prochain Crénaux" Then
Dim compteur As Integer
For compteur = 0 To 2000
If DateAVérifier.TotalSeconds < DateCourente.TotalSeconds Then
Dim nextOp As Date =
Window1.AutoProchaineOpération(DateAVérifier, Val(TextField8.Text),
PopupMenu1.SelectedRowIndex)
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) =
Str(nextOp.TotalSeconds, "00000000000000000000000")
DateAVérifier.TotalSeconds = nextOp.TotalSeconds
Else
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) =
Str(DateAVérifier.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) =
NomJourAbrégé(DateAVérifier) + " " + DateAVérifier.AbbreviatedDate + " -
" + DateAVérifier.LongTime
Exit
End If
Next
Else
ListBox1.Cell(ListBox1.SelectedRowIndex, 2) =
Str(DateAVérifier.TotalSeconds, "00000000000000000000000")
ListBox1.Cell(ListBox1.SelectedRowIndex, 3) =
NomJourAbrégé(DateAVérifier) + " " + DateAVérifier.AbbreviatedDate + " -
" + DateAVérifier.LongTime
End If
End If
' Modification des périodes automatiques
If SautePeriode = False And CheckBox1.Value = False Then
If ListBox1.Cell(ListBox1.SelectedRowIndex, 6) <>
Str(Val(TextField8.Text), "0") Or
ListBox1.Cell(ListBox1.SelectedRowIndex, 7) <>
Str(PopupMenu1.SelectedRowIndex) Then
ChangementPeriodeAuto.Visible = True
========== REMAINDER OF ARTICLE TRUNCATED ==========