Forum Liberty Basic France

Le 19/10/2017 à 23h22

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2480
Je remets ici un code de Castel, et j'ai un peu élagué les branches mortes de l'ancien post.
Code VB :
 
'----------------------------------------------------------------------------------
' Programme IdealPoids.bas Fait le 16 - fÈvrier 2017
' DerniËre Modifif le 17 - septembre 2017
'----------------------------------------------------------------------------------
    Dim taille$(200), age$(80)
    for i = 140 to 200 : taille$(i) = str$(i) : next i
    for i =  18 to  80 :    age$(i) = str$(i) : next i
   '-------------------------------------------------------------------------------
[InitColors]
    ForegroundColor$ = "Black"
    BackgroundColor$ = "Buttonface"
    TexteditorColor$ = "White"
    TextboxColor$    = "White"
    ComboboxColor$   = "lightgray"
    ListboxColor$    = "White"
[WindowSetup]
    nomainwin
    WindowWidth = 240
    WindowHeight = 400
    UpperLeftX = int((DisplayWidth- WindowWidth)/2)  'Centre la fenÍtre horizontalement ‡ l'Ècran
    UpperLeftY = int((DisplayHeight- WindowHeight)/2) 'Centre la fenÍtre verticalement ‡ l'Ècran
[GraphicSetup]
   '-------------------------------------------------------------------------------
    menu #main, "&File", "&Help", [Help], "&About", [About], |, "E&xit I.M.C.", [quit]
    button #main.button1, "Exit", [quit], UL, 135, 18, 80, 35
    button #main.button3, "OK", [OK], UL, 70, 295, 90, 35
    checkbox #main.cbx1, " Homme", [Homme], [waitHere],25, 80, 70, 20
    checkbox #main.cbx2, " Femme", [Femme], [waitHere],130, 80, 70, 20
   '-------------------------------------------------------------------------------
   'combobox #main, "backcolor 230 230 230"
   'ComboboxColor$ 230 230 230
   'print #main.combobox1, "backcolor 230 230 230"
    ComboboxColor$ = "buttonface"         '"buttonface"
    'ComboboxColor$ = "blue"
    combobox #main.combobox1, taille$(), [doCombo1], 130, 125, 80, 20
    combobox #main.combobox2,    age$(), [doCombo2], 130, 175, 80, 20
   '-------------------------------------------------------------------------------
    TextboxColor$ = "cyan"
    textbox #main.textbox15, 115, 230, 95, 40
   '-------------------------------------------------------------------------------
   'BackgroundColor$ = "lightgray"    'OK Áa marche
   'ForegroundColor$ = "darkblue"     'OK Áa marche
    open "Poids IdÈal - I M C" for graphics_nsb as #main
    print #main, "fill 230 230 230"
    print #main, "font ms_sans_serif 0 18"
    print #main, "trapclose [quit]"
    print #main.cbx1, "set"
   '.............................................................
    print #main, "backcolor 230 230 230"
    print #main, "color blue"
    print #main, "place 18 45"
   'print #main, "font arial 18 italic bold strikeout underscore"
    print #main, "font arial 24 italic bold "
    print #main, "\I.M.C."
   '.............................................................
    print #main, "place 15 140"
    print #main, "font arial 12 italic bold "
    print #main, "\Taille en cm"
   '.............................................................
    print #main, "place 15 190"
    print #main, "font arial 12 italic bold "
    print #main, "\Age (annÈes)"
   '.............................................................
    print #main, "color black"
    print #main, "place 15 245"
    print #main, "font arial 12 italic bold "
    print #main, "\Poids IdÈal"
    print #main, "\En Kilos"
   '.............................................................
    #main.textbox15, "!font ms_sans_serif 28 bold"
    wait
   '-------------------------------------------------------------------------------
[Help]
  notice "Version du Soft  V 2.5      "
 wait
 
[About]
  notice " I.M.C.  -->   Indice de Masse Corpoelle    "
 wait
 
[doCombo1]
 wait
 
[doCombo2]
 wait
 
[waitHere]
 wait
 
[Homme]
     print #main.cbx1, "set"
     print #main.cbx2, "reset"
     goto [waitHere]
   wait
 
[Femme]
     print #main.cbx2, "set"
     print #main.cbx1, "reset"
     goto [waitHere]
   wait
 
[quit]
    close #main
    End
 
[OK]
     ht$ = "" : ha$ = "" : ft$ = "" : fa$ = ""
     print #main.combobox1, "contents? ht$"
     print #main.combobox2, "contents? ha$"
 
       if ht$ = "" or ha$ = "" then
         #main.textbox15, " "
        goto [ici]
       end if
 
     ht$ = upper$(ht$) : ha$ = trim$(ha$)
 
     print #main.cbx1, "value? result1$"
     print #main.cbx2, "value? result2$"
 
     '/................................../
     '/          Homme                   /
     '/................................../
   if result1$ = "set" then
     t = 0 : a = 0 : p = 0
     t = val(ht$)
     a = val(ha$)
    'p = (t - 100) -((t - 150)/4) * 0.1
     p = t-100-((t-150)/4)+((a-20)/4)
     p = p - (p - int(p))
     #main.textbox15, " " + str$(p)
   end if
 
     '/................................../
     '/          Femme                   /
     '/................................../
   if result2$ = "set" then
     t = 0 : a = 0 : p = 0
     t = val(ht$)
     a = val(ha$)
    'p = (t - 100) -((t - 150)/2.5) * 0.1
     p = t-100-((t-150)/2.5)+((a-20)/6)
     p = p - (p - int(p))
     #main.textbox15, " " + str$(p)
   end if
     '-----------------------------------/
[ici]
 
 wait
 
     '................ Infos .......................
     ' Formule de Creff
     ' poids normal = (t - 100 + a / 10) * 0.9
     ' poids fine   = (t - 100 + a / 10) * 0.9 * 0.9
     ' poids large  = (t - 100 + a / 10) * 0.9 * 1.1
     '..............................................
     ' Formule de Lorenz
     ' Pour l'Homme:
     ' poids = (t - 100) -((t - 150)/4) * 0.1
     ' Pour la Femme:
     ' poids = (t - 100) -((t - 150)/2.5) * 0.1
     '..............................................
____________________
Roro

   
Le 19/10/2017 à 23h23

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2480
Ton code est bien propre et l'idée est pertinente.
Le "print" en tête des instructions est facultatif
Pour mettre le code en conteneur il faut mettre:
code=vb entre crochets avant et: /code entre crochets après

Je n'ai pas pu m'empêcher de faire une version sans checkbox
Code VB :
 
      NOMAINWIN
    Dim taille$(200), age$(80)
    for i = 140 to 200 : taille$(i) = str$(i) : next i
    for i =  18 to  80 :    age$(i) = str$(i) : next i
    WindowWidth = 240: WindowHeight = 365
    UpperLeftX = 100 : UpperLeftY = 20
    combobox #w.combobox1, taille$(), [doCombo1], 130, 80, 80, 20
    combobox #w.combobox2,    age$(), [doCombo2], 130, 120, 80, 20
    BUTTON #w.h, "Homme", [Homme], UL, 40, 170, 60, 25
    BUTTON #w.f, "Femme", [Femme], UL, 130, 170, 60, 25
    TextboxColor$ = "cyan"
    textbox #w.textbox15, 115, 230, 95, 40
    GRAPHICBOX #w.m 5, 5, 225, 300
    menu #w, "File", "Help", [Help], "About", [About], |, "Exit I.M.C.", [quit]
    OPEN "IMC" FOR window_nf AS #w
    #w, "TRAPCLOSE [quit]"
    #w.m , "down": #w.m, "fill 230 230 230"
    #w.m, "color blue; backcolor 230 230 230"
    #w.m, "font arial 24 italic bold "
    #w.m, "place 18 45": #w.m, "\I.M.C."
    #w.m, "font arial 12 italic bold "
    #w.m, "place 15 90": #w.m, "\Taille en cm"
    #w.m, "place 15 130": #w.m, "\Age (années)"
    #w.m, "place 15 250": #w.m, "\Poids idéal"
    #w.combobox1, "!Taille": #w.combobox2, "!Age"
    #w.combobox1, "reload": #w.combobox2, "reload"
    #w.textbox15, "!font ms_sans_serif 20 bold"
    '-------------
  wait
  [doCombo1]
    #w.combobox1, "contents? ht$": gosub [effpoint]
  wait
  [doCombo2]
    #w.combobox2, "contents? ha$": gosub [effpoint]
  wait
  [Homme]
    gosub [effpoint]: gosub [test]
    hh=1: ff=0: #w.m, "color red": #w.m, "place 60 205": #w.m, "size 10;set"
     t = 0 : a = 0 : p = 0
     t = val(ht$)
     a = val(ha$)
    'p = (t - 100) -((t - 150)/4) * 0.1
     p = t-100-((t-150)/4)+((a-20)/4)
     p = p - (p - int(p))
     #w.textbox15, " " + str$(p); " Kg"
  wait
  [Femme]
    gosub [effpoint]: gosub [test]
    ff=1: hh=0: #w.m, "color red": #w.m, "place 150 205": #w.m, "size 10;set"
     t = 0 : a = 0 : p = 0
     t = val(ht$)
     a = val(ha$)
    'p = (t - 100) -((t - 150)/2.5) * 0.1
     p = t-100-((t-150)/2.5)+((a-20)/6)
     p = p - (p - int(p))
     #w.textbox15, " " + str$(p); " Kg"
  wait
  [effpoint]
    #w.m, "color 230 230 230; backcolor 230 230 230"
    #w.m, "place 5 192": #w.m, "boxfilled 210 220"
  return
  [test]
    if ht$="" or ha$="" then
      gosub [effpoint]
      #w.m, "color red": #w.m, "place 10 205": #w.m, "\ Donnée(s) manquante(s)"
      wait
    end if
  return
[Help]
  notice "Version du Soft  V 2.5      "
 wait
[About]
  notice " I.M.C.  -->   Indice de Masse Corpoelle    "
 wait
  [quit]
    CLOSE  #w
    END
 
____________________
Roro

   
Le 19/10/2017 à 23h25

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2480
Si tu veux poster des trucs contenant des bmp's; et donc sous forme de dossiers, il faut les compresser en zip (avec par exemple "IZarc" ou "ZipGenius"(gratuits))
Quand tu a le zip, tu va dans ton profil (à gauche dans la barre du haut de page) puis: "Gestion des Fichiers" et dans la nouvelle fenêtre: "Ajouter un Fichier"(à droite). Cela t'ouvre ton explorateur Windows, tu sélectionne le zip + "Ouvrir" et en bas de la page des fichiers tu clique sur: "Uploader".(tu attends que ça uploade)
Pour mettre le lien du zip dans le message du forum, c'est l'icône "nuage" à droite de la barre d'outils qui t'envoie dans ton stockage et là c'est la flèche sous le fichier qui mettra le lien dans le msg.
N'hésite pas à demander des explic's en cas de soucis.
____________________
Roro

   

 |  |

1 Utilisateur en ligne : 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne : Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie