Page 2 sur 2

Publié : lun. 14/nov./2005 10:46
par AWEAR
Pfffff rien de plus simple ! :D
Au lieu de mettre cb=#String_cb
cr=#String_cr
(ca retourne le numéro du gadget mais pas ce qu'il y a dedans)
il faut mettre
cb=val(getgadgettext(#String_cb))
cr=val(getgadgettext(#String_cr))
qui retourne la valeur du string dans le gadget
il faut aussi remplacer
SetGadgetText(#String_totalc,""+Total)
par SetGadgetText(#String_totalc,""+str(Total))
voilà

Publié : lun. 14/nov./2005 10:50
par Droopy

Code : Tout sélectionner


;exemple d'un bon de commande 

; constante de la fenetre et des gadgets 
; 
Enumeration 
  #Window_0 
EndEnumeration 
Enumeration 
  #Text_titre 
  #Text_nom 
  #String_nom 
  #Text_adresse 
  #String_adresse 
  #Text_ville 
  #String_ville 
  #Text_carteB 
  #String_cb 
  #Text_carteR 
  #String_cr 
  #Text_prixU 
  #String_prixU 
  #Text_totalc 
  #String_totalc 
  #Text_Total 
  #String_7 
  #Button_Calcule 
  #Button_Effacer 
  #Button_Quit 
EndEnumeration 
  
  
; Fonts 
Global FontID1 
FontID1 = LoadFont(1, "Times New Roman", 24, #PB_Font_Bold) 
Global FontID2 
FontID2 = LoadFont(2, "Times New Roman", 12) 



Global cb 
Global cr 


Procedure effacer() 
  If CreateGadgetList(WindowID()) 
    SetGadgetText(#String_nom,"") 
    SetGadgetText(#String_adresse,"") 
    SetGadgetText(#String_ville,"") 
    SetGadgetText(#String_cb,"") 
    SetGadgetText(#String_cr,"") 
    SetGadgetText(#String_totalc,"") 
    SetGadgetText(#String_7,"") 
    ActivateGadget(#String_nom) 
    
  EndIf 
  
EndProcedure 
Procedure calculer() 
  cb=Val(GetGadgetText(#String_cb))
  cr=Val(GetGadgetText(#String_cr))
  
  
  Total=cb+cr 
   
  SetGadgetText(#String_totalc,Str(Total)) 
  
  
  
  
EndProcedure 
  
  
Procedure main() 
  
  If OpenWindow(#Window_0,0,0,642,482,#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered,"Bon de commande")                                  
    If CreateGadgetList(WindowID()) 
      TextGadget(#Text_titre, 60, 25, 525, 40,"Bon de commande de magic-shop", #PB_Text_Center) 
      SetGadgetFont(#Text_titre, FontID1) 
      TextGadget(#Text_nom, 10, 105, 65, 20," Nom :", #PB_Text_Center) 
      SetGadgetFont(#Text_nom, FontID2) 
      StringGadget(#String_nom, 85, 105, 230, 25, "") 
      TextGadget(#Text_adresse, 15, 150, 65, 25, "Adresse :", #PB_Text_Center) 
      SetGadgetFont(#Text_adresse, FontID2) 
      StringGadget(#String_adresse, 85, 150, 230, 25, "") 
      TextGadget(#Text_ville, 5, 195, 60, 25, "Ville :", #PB_Text_Center) 
      SetGadgetFont(#Text_ville, FontID2) 
      StringGadget(#String_ville, 85, 200, 230, 25, "") 
      TextGadget(#Text_carteB, 10, 270, 95, 20, "Carte bleue :", #PB_Text_Center) 
      SetGadgetFont(#Text_carteB, FontID2) 
      StringGadget(#String_cb, 115, 270, 45, 25, "",#PB_String_Numeric) 
      TextGadget(#Text_carteR, 20, 320, 80, 25, "Carte rouge :", #PB_Text_Center) 
      SetGadgetFont(#Text_carteR, FontID2) 
      StringGadget(#String_cr, 115, 320, 45, 25, "",#PB_String_Numeric) 
      TextGadget(#Text_prixU, 370, 100, 90, 20, "prix unitaire :",#PB_Text_Center) 
      SetGadgetFont(#Text_prixU, FontID2) 
      StringGadget(#String_prixU, 495, 100, 55, 30, "",#PB_String_Numeric) 
      TextGadget(#Text_totalc, 365, 170, 115, 20, "Total des cartes :", #PB_Text_Center) 
      SetGadgetFont(#Text_totalc, FontID2) 
      StringGadget(#String_totalc, 495, 165, 55, 30, "", #PB_String_ReadOnly|#PB_String_Numeric) 
      TextGadget(#Text_Total, 360, 225, 65, 25, "Total :", #PB_Text_Center) 
      SetGadgetFont(#Text_Total, FontID2) 
      StringGadget(#String_7, 495, 220, 55, 30, "", #PB_String_ReadOnly|#PB_String_Numeric) 
      ButtonGadget(#Button_Calcule, 30, 395, 135, 40, "Calculer") 
      GadgetToolTip(#Button_Calcule, "Calculer la commande ") 
      SetGadgetFont(#Button_Calcule, FontID2) 
      ButtonGadget(#Button_Effacer, 240, 395, 135, 40, "Effacer") 
      GadgetToolTip(#Button_Effacer, " effacer les champs") 
      SetGadgetFont(#Button_Effacer, FontID2) 
      ButtonGadget(#Button_Quit, 450, 395, 135, 40, "Quitter") 
      SetGadgetFont(#Button_Quit, FontID2) 
      
    EndIf 
  EndIf 
EndProcedure 
  
  
main() 
  
Repeat 
  event=WaitWindowEvent() 
  Select event 
    Case #PB_Event_Gadget 
      Select EventGadgetID() 
        Case #Button_Calcule:calculer() 
        Case #Button_Effacer:effacer() 
        Case #Button_Quit: 
          fermer=1 
      EndSelect 
      
      
    Case #PB_Event_CloseWindow 
      fermer=1 
  EndSelect 
Until fermer=1 
End 

Publié : lun. 14/nov./2005 11:38
par bernard13
merci

Publié : lun. 14/nov./2005 12:28
par nico
Cela fait plusieurs années maintenant que tu es inscrit; et faire de la programmation avec aussi peu de sens logique est vraiment très étonnant. Je ne sais pas si c'est formidable ou navrant mais en en tout cas tu démontres plus de capacité à vouloir qu'à faire!

Sur quoi programmes tu réellement?

car je crois savoir que tu as un license de Ibasic et de Multimedia!

Publié : lun. 14/nov./2005 14:49
par bernard13
j'ai pas le trop le temps de programmer Nico