Tiens, un petit code d'exemple avec seulement les billets, pour le reste, c'est la même chose.
Tel que c'est, c'est assez similaire au formules que tu rentre dans les cellules du tableur, mais c'est assez facile de simplifier tout ça en passant par une procédure qui se chargerait du calcul, plutôt que de repeter le même code à chaque gadget.
Le forum n'affiche pas le symbole de l'euro, et donc, dans les SetGadgetText(), il est remplacé par une barre verticale.
Code : Tout sélectionner
;- Window Constants
Enumeration
#Win_0
EndEnumeration
;- Gadget Constants
Enumeration
#Txt_0
#Txt_TitreBillet
#Txt_500
#Txt_200
#Txt_100
#Txt_50
#Txt_20
#Txt_10
#Txt_5
#Str_Nb500
#Str_Nb200
#Str_Nb100
#Str_Nb50
#Str_Nb20
#Str_Nb10
#Str_Nb5
#Txt_Total500
#Txt_Total200
#Txt_Total50
#Txt_Total100
#Txt_Total20
#Txt_Total10
#Txt_Total5
#Txt_TotalBillets
#Txt_TitreValeur
#Txt_TitreNbre
#Txt_TitreTotal
EndEnumeration
;- Fonts
Global FontID1, FontID2
FontID1 = LoadFont(1, "Arial", 14, #PB_Font_Bold)
FontID2 = LoadFont(2, "Arial", 12, #PB_Font_Bold)
DefType.f Montant500,Montant200,Montant100,Montant50,Montant20,Montant10,Montant5,General
Procedure Open_Win_0()
If OpenWindow(#Win_0, 216, 0, 394, 240, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Caisse exemple")
If CreateGadgetList(WindowID())
TextGadget(#Txt_0, 5, 5, 200, 25, "Relevé de caisse du:")
; Le gadget du titre aura une police Arial 14
SetGadgetFont(#Txt_0, FontID1)
; Tous les autres auront une police Arial 12
SetGadgetFont(#PB_Default, FontID2)
TextGadget(#Txt_TitreBillet, 10, 50, 70, 20, "Billets")
TextGadget(#Txt_500, 145, 80, 60, 20, "500,00", #PB_Text_Right)
TextGadget(#Txt_200, 145, 100, 60, 20, "200,00", #PB_Text_Right)
TextGadget(#Txt_100, 145, 120, 60, 20, "100,00", #PB_Text_Right)
TextGadget(#Txt_50, 145, 140, 60, 20, "50,00", #PB_Text_Right)
TextGadget(#Txt_20, 145, 160, 60, 20, "20,00", #PB_Text_Right)
TextGadget(#Txt_10, 145, 180, 60, 20, "10,00", #PB_Text_Right)
TextGadget(#Txt_5, 145, 200, 60, 20, "5,00", #PB_Text_Right)
StringGadget(#Str_Nb500, 210, 80, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb200, 210, 100, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb100, 210, 120, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb50, 210, 140, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb20, 210, 160, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb10, 210, 180, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
StringGadget(#Str_Nb5, 210, 200, 50, 20, "", #PB_String_Numeric|#ES_RIGHT)
TextGadget(#Txt_Total500, 270, 80, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total200, 270, 100, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total50, 270, 140, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total100, 270, 120, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total20, 270, 160, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total10, 270, 180, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_Total5, 270, 200, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_TotalBillets, 10, 80, 105, 20, "", #PB_Text_Right | #PB_Text_Border)
TextGadget(#Txt_TitreValeur, 145, 50, 60, 20, "Valeur")
TextGadget(#Txt_TitreNbre, 210, 50, 50, 20, "Nbre")
TextGadget(#Txt_TitreTotal, 265, 50, 105, 20, "Total")
EndIf
EndIf
ActivateGadget(#Str_Nb500)
EndProcedure
Open_Win_0()
Repeat
Select WaitWindowEvent()
Case #PB_EventGadget
Select EventGadgetID()
Case #Str_Nb500
If EventType() = #PB_EventType_Change
Montant500 = Val(GetGadgetText(#Str_Nb500))*500
SetGadgetText(#Txt_Total500,StrF(Montant500,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb200
If EventType() = #PB_EventType_Change
Montant200 = ValF(GetGadgetText(#Str_Nb200))*200
SetGadgetText(#Txt_Total200,StrF(Montant200,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb100
If EventType() = #PB_EventType_Change
Montant100 = Val(GetGadgetText(#Str_Nb100))*100
SetGadgetText(#Txt_Total100,StrF(Montant100,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb50
If EventType() = #PB_EventType_Change
Montant50 = Val(GetGadgetText(#Str_Nb50))*50
SetGadgetText(#Txt_Total50,StrF(Montant50,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb20
If EventType() = #PB_EventType_Change
Montant20 = Val(GetGadgetText(#Str_Nb20))*20
SetGadgetText(#Txt_Total20,StrF(Montant20,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb10
If EventType() = #PB_EventType_Change
Montant10 = Val(GetGadgetText(#Str_Nb10))*10
SetGadgetText(#Txt_Total10,StrF(Montant10,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
Case #Str_Nb5
If EventType() = #PB_EventType_Change
Montant5 = Val(GetGadgetText(#Str_Nb5))*5
SetGadgetText(#Txt_Total5,StrF(Montant5,2)+ " €" )
General = Montant500+Montant200+Montant100+Montant50+Montant20+Montant10+Montant5
SetGadgetText(#Txt_TotalBillets, StrF(General,2)+" €")
EndIf
EndSelect
Case #PB_EventCloseWindow
Quit = #True
EndSelect
Until Quit
End
Voilà, c'est ma dernière contribution pour un bon moment, je termine mon déménagement demain, et mon accès internet sera coupé demain dans la matinée.
Alors à plus tout le monde, et à bientôt, j'espère.