Pour ne pas rester en reste:
Code : Tout sélectionner
Define.d a = 10.5789474123 ;*******************
Enumeration
#Ma_fen
#btCalcul
#str0
#str1
#txt0
#text1
EndEnumeration
Procedure.D Round_decimal(nombre.d, dec.d)
ProcedureReturn Int(nombre * Pow(10, dec) + 0.5) / Pow(10, dec)
EndProcedure
OpenWindow(#Ma_fen, 0, 0, 400, 300, "Round_Decimal", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(#str0, 40, 50, 300, 25, StrD(a))
TextGadget(#txt0, 40, 100, 110, 25, "Nombre de décimales:")
StringGadget(#str1, 150, 95, 20, 25, "2")
TextGadget(#text1, 40, 150, 300, 25, "", #PB_Text_Border)
ButtonGadget(#btCalcul, 150, 200, 80, 30, "Calculer")
; Boucle générale
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
Case #btCalcul
Select EventType()
Case #PB_EventType_LeftClick
a = ValD(GetGadgetText(#str0))
SetGadgetText(#text1, StrD(Round_decimal(a, Val(GetGadgetText(#str1)))))
EndSelect
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
End
Microsoft Windows 10 Famille 64 bits : Carte mère : ASRock 970 Extreme3 R2.0 : Carte Graphique NVIDIA GeForce RTX 3080 : Processeur AMD FX 6300 6 cœurs 12 threads 3,50 GHz PB 6.20 LTS (x64)
Un homme doit être poli, mais il doit aussi être libre !