Bonjou à tous,
Dans mon code sql, je liste le contenu de 3 tables dans 3 combox.
En modifiant pour chaque fonction le contenu de différents paramètres
$SQLCode
$NameList
$toto = GUICtrlSetData($paramCombox, $ContenuTable);
► Afficher le textecode fonction
Code : Tout sélectionner
WIN_CONNECTION() ; liste les os
Office_Connection() ; liste office version
Virus_Connection() ; liste antivirus
Func WIN_CONNECTION()
Local $SQLCode = [color=#FF0000]"SELECT * FROM win"[/color]
$TableContents = _Query($SQLInstance, $SQLCode)
With $TableContents
While Not .EOF
; STOCKAGE DES RéSULTATS DANS UN TABLEAU
$NameList &= "|" & .Fields("[color=#FF0000]Nom_Win[/color]" ).value ;; No @CRLF for a list or Combo
.MoveNext
WEnd
[color=#FF0000]$toto = GUICtrlSetData($ListOsType, $NameList);setting to combobox[/color]
EndWith
EndFunc ;==>WIN_CONNECTION
Func Virus_Connection()
[color=#FF0000]Local $SQLCode ="SELECT * FROM virus"[/color]
$TableContents = _Query($SQLInstance, $SQLCode)
With $TableContents
While Not .EOF
; STOCKAGE DES RéSULTATS DANS UN TABLEAU
[color=#FF0000]$NameList2 &= "|" & .Fields("Nom_ANTIVIRUS" ).value ;; No @CRLF for a list or Combo[/color]
.MoveNext
WEnd
[color=#FF0000] $toto = GUICtrlSetData($ListAntivirus, $NameList2)[/color];setting to combobox
EndWith
EndFunc ;==>Virus_Connection
Func Office_Connection()
[color=#FF0000] Local $SQLCode = "SELECT * FROM veroffice"[/color]
$TableContents = _Query($SQLInstance, $SQLCode)
With $TableContents
While Not .EOF
; STOCKAGE DES RéSULTATS DANS UN TABLEAU
$[color=#BF0000]NameList3 &= "|" & .Fields("Nom_Office" ).value[/color] ;; No @CRLF for a list or Combo
.MoveNext
WEnd
[color=#BF0000]$toto = GUICtrlSetData($ListOffice, $NameList3)[/color];setting to combobox
EndWith
EndFunc ;==>Office_Connection
Est il possible de simplifer le code en une fonction qui chargerait la meme chose avec 3 paramètres qui changeraient ?
genre :
Code : Tout sélectionner
Func _ListCombox($parm_1,$param_2,$parm_3)
Blablabl
Return je sais pas quoi ??
EndFunc
ou
Func _ListCombox($SQLCode,$Champ,$Combox)
????
Return ??
EndFunc
Me resterait à remplacer ceci :
WIN_CONNECTION() ; liste les os
Office_Connection() ; liste office version
Virus_Connection() ; liste antivirus
Par cela :
_ListCombox("SELECT * FROM veroffice","Nom_Office",$ListOffice)
_ListCombox("SELECT * FROM virus","Nom_ANTIVIRUS",$ListAntivirus)
Et avoir une seule fonction pour les 3 combox
Est ce possible ou non ?
si oui comment faire ?
J'ai regardé l'aide mais je ne vois pas comment mettre les 3 variables en paramètres... avec le return.
Aperçu de la gui :
Merci d'avance
Laddy