Forum Liberty Basic France

Général » Petite calculatrice très simple. Fonctionne à la souris ou/et au clavier.
Le 29/04/2012 à 08h07

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Tout est dans le titre ;)

Code VB :
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.)

 
    nomainwin
 
    global number, sign$, disp$, res$, result
    DIM num$(2)
 
'Textbox
    textbox #calc.txt, 5, 5, 110, 25
 
'Ghost window
    graphicbox #calc.gr, 0, 0, 1, 1
 
'Number Buttons
    button #calc.7, " 7 ", num, UL,  5, 34
    button #calc.8, " 8 ", num, UL, 44, 34
    button #calc.9, " 9 ", num, UL, 83, 34
    button #calc.4, " 4 ", num, UL,  5, 63
    button #calc.5, " 5 ", num, UL, 44, 63
    button #calc.6, " 6 ", num, UL, 83, 63
    button #calc.1, " 1 ", num, UL,  5, 92
    button #calc.2, " 2 ", num, UL, 44, 92
    button #calc.3, " 3 ", num, UL, 83, 92
    button #calc.0, " 0 ", num, UL, 44, 121
 
'Other Buttons
    button #calc.c, " C ", num,  UL, 122, 5
    button #calc.e, " = ", num,  UL, 83, 121
    button #calc.t, " x ", num,  UL, 122, 34
    button #calc.d, " / ", num,  UL, 122, 63
    button #calc.m, " - ", num,  UL, 122, 92
    button #calc.p, " + ", num,  UL, 122, 121
    button #calc.L, " . ", num,  UL, 5, 122
 
'hight and width of window
    WindowWidth = 168
    WindowHeight = 177
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
'Window
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 


avec une excellente astuce de la fenêtre graphique fantôme, trouvée par NJames pour pouvoir prendre en compte le clavier + quelques corrections de tsh73 pour quelques contraintes d'utilisation de "select case".



Edité par cassiope01 Le 29/04/2012 à 10h49
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 29/04/2012 à 13h19

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Ce qui serait sympa, et que j'ai envie de faire depuis qu'on m'a braqué un HP67.(il y a 30 ans). C'est une petite calculatrice à notation (ou rotation) polonaise inverse avec une pile à plus de deux accés.Avec un affichage complet de la pile, un index d'ordre d'entrée et une rotation complète, plus quelques mémoires, un registre....Houla, la petite calculatrice prend de l'embompoint. C'est toujours comme ça...On commence petit... et on fini avec une usine à gaz...et le gaz, c'est dangereux ! ;)
Pour ceux qui savent pas; la RPN, c'est: ex: 5 >ENTER ( Sous la pile)>8 > + > Résultat (pas de =). Au lieu de 5 + 8=
ça permet de faire tourner ce qu'il y a dans la pile, c'est bien pratique à l'usage. Quand on y a gouté, on ne peut plus s'en passer.
Bon voyons voir l'astuce de la fenetre fantome, et les "petites modifs" de Cassiope . :p
____________________
Roro

   
Le 16/05/2012 à 21h55

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Alors comme ça tu t'en prends à mon monopoly.
ma vengence sera terrible...La voilà: ;)

Code JB :
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar
 
  nomainwin
    WindowWidth = 200
    WindowHeight = 300
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 1, 1  'Ghost window
 
    button #calc.r, "sto", num, UL, 122, 5
    button #calc.s, "sto", num, UL, 122, 30
    button #calc.u, "sto", num, UL, 122, 55
    button #calc.v, "sto", num, UL, 122, 80
      button #calc.w, "rcl", num, UL,155, 5
      button #calc.x, "rcl", num, UL,155, 30
      button #calc.y, "rcl", num, UL,155, 55
      button #calc.z, "rcl", num, UL, 155, 80
     button #calc.q, "CM", num, UL, 155, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 221
 
    button #calc.L, " . ", num,  UL, 5, 222
    button #calc.c, " C ", num,  UL, 122, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 122, 134
    button #calc.d, " / ", num,  UL, 122, 163
    button #calc.m, " - ", num,  UL, 122, 192
    button #calc.p, " + ", num,  UL, 122, 221
    button #calc.e, " = ", num,  UL, 83, 221
    'button #calc.q, "ent", ent,  UL, 120, 221
 
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?
 
 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
             case n$ = "v"
             v$=disp$
             #calc.tz v$
             case n$ = "u"
             u$=disp$
             #calc.ty u$
             case n$ = "s"
             s$=disp$
             #calc.tx s$
             case n$ = "r"
             r$=disp$
             #calc.tw r$
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
            case n$="z"
            num$(number)=v$
            disp$ = num$(number)
        'result = 0
                    case n$="y"
            num$(number)=u$
            disp$ = num$(number)
       ' result = 0
                    case n$="x"
            num$(number)=s$
            disp$ = num$(number)
       ' result = 0
                    case n$="w"
            num$(number)=r$
            disp$ = num$(number)
       ' result = 0
       case n$ = "q"
       #calc.tw  "":r=0
       #calc.tx  "":s=0
       #calc.ty  "":u=0
       #calc.tz  "":v=0
 
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
 




Edité par Roland Le 17/05/2012 à 13h40
____________________
Roro

   
Le 17/05/2012 à 11h44

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Une petite modif:

Code JB :
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar
 
  nomainwin
    WindowWidth = 210
    WindowHeight = 300
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
   STATICTEXT #calc, "z", 120, 60, 5, 15
   STATICTEXT #calc, "y", 120, 85, 5, 15
   STATICTEXT #calc, "x", 120, 110, 5, 15
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 1, 1  'Ghost window
 
 
     button #calc.k, "yxz", num, UL, 165, 134
     button #calc.n, "y/z", num, UL, 165, 163
     button #calc.o, "y-z", num, UL, 165, 192
     button #calc.j, "y+z", num, UL, 165, 222
    button #calc.r, "sto", num, UL, 132, 5
    button #calc.s, "sto", num, UL, 132, 30
    button #calc.u, "sto", num, UL, 132, 55
    button #calc.v, "sto", num, UL, 132, 80
      button #calc.w, "rcl", num, UL,165, 5
      button #calc.x, "rcl", num, UL,165, 30
      button #calc.y, "rcl", num, UL,165, 55
      button #calc.z, "rcl", num, UL, 165, 80
     button #calc.q, "Cm ", num, UL, 165, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 221
 
    button #calc.L, " . ", num,  UL, 5, 222
    button #calc.c, " C ", num,  UL, 132, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 122, 134
    button #calc.d, " / ", num,  UL, 122, 163
    button #calc.m, " - ", num,  UL, 122, 192
    button #calc.p, " + ", num,  UL, 122, 221
    button #calc.e, " = ", num,  UL, 83, 221
    'button #calc.q, "ent", ent,  UL, 120, 221
 
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?
 
 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
             case n$ = "v"
                v$=disp$
                #calc.tz v$
             case n$ = "u"
                u$=disp$
                #calc.ty u$
             case n$ = "s"
                s$=disp$
                #calc.tx s$
             case n$ = "r"
                r$=disp$
                #calc.tw r$
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
          case n$="z"
               num$(number)=v$
               disp$ = num$(number)
              'result = 0
           case n$="y"
               num$(number)=u$
               disp$ = num$(number)
             ' result = 0
           case n$="x"
               num$(number)=s$
               disp$ = num$(number)
             ' result = 0
            case n$="w"
               num$(number)=r$
               disp$ = num$(number)
             ' result = 0
 
       case n$ = "q"  ' efface box mémoires/raz var mémoires
          #calc.tw  "":r=0
          #calc.tx  "":s=0
          #calc.ty  "":u=0
          #calc.tz  "":v=0
 
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="k"
          num$(number) = str$(val(v$)*val(u$))
          disp$ = num$(number)
       case n$="n"
       num$(number) = str$(val(v$)/val(u$))
       disp$ = num$(number)
       case n$="o"
           num$(number) = str$(val(v$)-val(u$))
          case n$="j"
          num$(number) = str$(val(v$)+val(u$))
       disp$ = num$(number)
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
 




Edité par Roland Le 17/05/2012 à 14h06
____________________
Roro

   
Le 17/05/2012 à 14h27

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Et encore une:

Code JB :
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar
 
  nomainwin
    WindowWidth = 245
    WindowHeight = 300
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
   STATICTEXT #calc, "z", 120, 60, 5, 15
   STATICTEXT #calc, "y", 120, 85, 5, 15
   STATICTEXT #calc, "x", 120, 110, 5, 15
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 1, 1  'Ghost window
 
     button #calc.k, "yxz", num, UL, 200, 134
     button #calc.n, "y/z", num, UL, 200, 163
     button #calc.o, "y-z", num, UL, 200, 192
     button #calc.j, "y+z", num, UL, 200, 222
      button #calc.f, "xxy", num, UL, 165, 134
      button #calc.g, "x/y", num, UL, 165, 163
      button #calc.h, "x-y", num, UL, 165, 192
      button #calc.i, "x+y", num, UL, 165, 222
    button #calc.r, "sto", num, UL, 132, 5
    button #calc.s, "sto", num, UL, 132, 30
    button #calc.u, "sto", num, UL, 132, 55
    button #calc.v, "sto", num, UL, 132, 80
      button #calc.w, "rcl", num, UL,165, 5
      button #calc.x, "rcl", num, UL,165, 30
      button #calc.y, "rcl", num, UL,165, 55
      button #calc.z, "rcl", num, UL, 165, 80
     button #calc.q, "Cm ", num, UL, 165, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 221
 
    button #calc.L, " . ", num,  UL, 5, 222
    button #calc.c, " C ", num,  UL, 132, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 122, 134
    button #calc.d, " / ", num,  UL, 122, 163
    button #calc.m, " - ", num,  UL, 122, 192
    button #calc.p, " + ", num,  UL, 122, 221
    button #calc.e, " = ", num,  UL, 83, 221
    'button #calc.q, "ent", ent,  UL, 120, 221
 
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?
 
 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
       case n$ = "v"
          v$=disp$
          #calc.tz v$
       case n$ = "u"
          u$=disp$
          #calc.ty u$
       case n$ = "s"
          s$=disp$
          #calc.tx s$
       case n$ = "r"
          r$=disp$
          #calc.tw r$
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
  'stockage
        case n$="z"
            num$(number)=v$
            disp$ = num$(number)
        case n$="y"
            num$(number)=u$
            disp$ = num$(number)
        case n$="x"
            num$(number)=s$
            disp$ = num$(number)
        case n$="w"
            num$(number)=r$
            disp$ = num$(number)
 
       case n$ = "q"  ' efface box mémoires/raz var mémoires
          #calc.tw  "":r=0
          #calc.tx  "":s=0
          #calc.ty  "":u=0
          #calc.tz  "":v=0
   'opère y > z
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="k"
          num$(number) = str$(val(v$)*val(u$))
          disp$ = num$(number)
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="o"
          num$(number) = str$(val(v$)-val(u$))
          disp$ = num$(number)
       case n$="j"
          num$(number) = str$(val(v$)+val(u$))
          disp$ = num$(number)
   'opère x > y
       case n$="f"
          num$(number) = str$(val(num$(number))*val(v$))
          disp$ = num$(number)
       case n$="g"
          num$(number) = str$(val(num$(number))/val(v$))
          disp$ = num$(number)
       case n$="h"
          num$(number) = str$(val(num$(number))-val(v$))
          disp$ = num$(number)
       case n$="i"
          num$(number) = str$(val(num$(number))+val(v$))
          disp$ = num$(number)
 
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
 
 
 
 




Edité par Roland Le 18/05/2012 à 10h51
____________________
Roro

   
Le 17/05/2012 à 14h36

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Avec taille des bouttons à convenance :

Code VB :
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.)

    nomainwin
 
    global number, sign$, disp$, result
    DIM num$(2)
    buttonSizeX = 90  'mini 38
    buttonSizeY = 60  'mini 25
    CalcPosX = 5    'position x,y if I want to include this calc in a bigger application...
    CalcPosY = 5
 
'Textbox
    textbox #calc.txt, CalcPosX+6, CalcPosY+5, 110, 25
 
'Ghost window
    graphicbox #calc.gr, 0, 0, 1, 1
 
'Number Buttons
    button #calc.7, " 7 ", num, UL, CalcPosX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.8, " 8 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.9, " 9 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.4, " 4 ", num, UL, CalcPosX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.5, " 5 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.6, " 6 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.1, " 1 ", num, UL, CalcPosX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.2, " 2 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.3, " 3 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.0, " 0 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'Other Buttons
    button #calc.c, " C ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+3,   buttonSizeX, buttonSizeY
    button #calc.t, " x ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+buttonSizeY+3,  buttonSizeX, buttonSizeY
    button #calc.d, " / ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(2*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.m, " - ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(3*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.p, " + ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.e, " = ", num,  UL, CalcPosX+2*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.L, " . ", num,  UL, CalcPosX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'hight and width of window
    WindowWidth = 18 + 4*buttonSizeX  '168
    WindowHeight = 44 + 5*buttonSizeY '184
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
'Window
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$ 
 
    ButtonFontSize = int(buttonSizeY/3)    'scale text
    for b = 0 to 16
        if b<10 then butt$ = "#calc."+str$(b) else butt$ = "#calc."+word$("c t d m p e L",b-9)
        #butt$ "!font Times_New_Roman ";ButtonFontSize
    next
 
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
    case instr("0123456789",n$)>0   'numbers
        if result = 0 then num$(number) = num$(number) + n$ else num$(number) = n$
        disp$ = num$(number)
        result = 0
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)     'operator
        if sign$ <> "" and val(num$(2)) <> 0 then
            disp$ = compute$(num$(1),num$(2),sign$)
            num$(1) = disp$
            num$(2) = ""
        end if
        sign$ = word$("+ - x /",instr("pmtd",n$))  'new operator
        number = 2
        result = 1
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
        result = 0
 
    case (n$ = "e" and sign$ <> "")   'result (" = ")
        disp$ = compute$(num$(1),num$(2),sign$)
        sign$ = ""
        num$(1) = disp$    ' go on with last result...
        num$(2) = ""
        result = 1
        number = 2
 
    end select
 
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    #calc.txt space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.gr "setfocus"
end sub
 
function compute$(num1$,num2$,sig$)
    select case sig$
    case "+" :compute$ = str$(val(num1$) + val(num2$))
    case "-" :compute$ = str$(val(num1$) - val(num2$))
    case "x" :compute$ = str$(val(num1$) * val(num2$))
    case "/" :compute$ = str$(val(num1$) / val(num2$))
    end select
   ' print num1$;" ";sig$;" ";num2$;" = ";compute$
end function
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 




Edité par cassiope01 Le 17/05/2012 à 17h52
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 17/05/2012 à 17h21

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
ça c'est pas mal, j'ai mis: 240 x 140 pour les boutons, et y'a un truc qui saute aux yeux, tu crois qu'on peut faire quelque chose ? ;).......
.......Oui ! un textbox de 600 x 100 et new roman 48 ....Super !
Mais y'a un problème: la makina no marcha plou !!!! :s



Edité par Roland Le 17/05/2012 à 17h40
____________________
Roro

   
Le 17/05/2012 à 18h17

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Rectifié :

Code VB :
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.)

    nomainwin
 
    global number, sign$, disp$, result
    DIM num$(2)
    buttonSizeX = 90  'mini 38
    buttonSizeY = 50  'mini 25
    CalcPosX = 5    'position x,y if I want to include this calc in a bigger application...
    CalcPosY = 5
 
'Textbox
    textbox #calc.txt, CalcPosX+2, CalcPosY+4, 3*buttonSizeX-5, buttonSizeY-4
 
'Ghost window
    graphicbox #calc.gr, 0, 0, 1, 1
 
'Number Buttons
    button #calc.7, " 7 ", num, UL, CalcPosX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.8, " 8 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.9, " 9 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.4, " 4 ", num, UL, CalcPosX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.5, " 5 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.6, " 6 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.1, " 1 ", num, UL, CalcPosX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.2, " 2 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.3, " 3 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.0, " 0 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'Other Buttons
    button #calc.c, " C ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+3,   buttonSizeX, buttonSizeY
    button #calc.t, " x ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+buttonSizeY+3,  buttonSizeX, buttonSizeY
    button #calc.d, " / ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(2*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.m, " - ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(3*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.p, " + ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.e, " = ", num,  UL, CalcPosX+2*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.L, " . ", num,  UL, CalcPosX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'hight and width of window
    WindowWidth = 18 + 4*buttonSizeX  '168
    WindowHeight = 44 + 5*buttonSizeY '184
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
'Window
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
 
'Buttons and result display
    CalcTextFont = int(buttonSizeX/4)   'scale text
    #calc.txt "!font Times_New_Roman ";CalcTextFont
    disp$ = "0"
    #calc.txt rightJustified$(disp$)  'right justified !?  ( with font Times_New_Roman 10 )
    ButtonFontSize = int(buttonSizeY/3)    'scale buttons text
    for b = 0 to 16
        if b<10 then butt$ = "#calc."+str$(b) else butt$ = "#calc."+word$("c t d m p e L",b-9)
        #butt$ "!font Times_New_Roman ";ButtonFontSize
    next
    number = 1
 
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
function rightJustified$(text$)
    rightJustified$ = space$(32-len(text$)*2)+text$
end function
 
sub num handle$
    n$ = right$(handle$,1)
    select case
    case instr("0123456789",n$)>0   'numbers
        if result = 0 then num$(number) = num$(number) + n$ else num$(number) = n$
        disp$ = num$(number)
        result = 0
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)     'operator
        if sign$ <> "" and val(num$(2)) <> 0 then
            disp$ = compute$(num$(1),num$(2),sign$)
            num$(1) = disp$
            num$(2) = ""
        end if
        sign$ = word$("+ - x /",instr("pmtd",n$))  'new operator
        number = 2
        result = 1
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
        result = 0
 
    case (n$ = "e" and sign$ <> "")   'result (" = ")
        disp$ = compute$(num$(1),num$(2),sign$)
        sign$ = ""
        num$(1) = disp$    ' go on with last result...
        num$(2) = ""
        result = 1
        number = 1
 
    end select
 
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    #calc.txt rightJustified$(disp$)  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.gr "setfocus"
end sub
 
function compute$(num1$,num2$,sig$)
    select case sig$
    case "+" :compute$ = str$(val(num1$) + val(num2$))
    case "-" :compute$ = str$(val(num1$) - val(num2$))
    case "x" :compute$ = str$(val(num1$) * val(num2$))
    case "/" :compute$ = str$(val(num1$) / val(num2$))
    end select
   ' print num1$;" ";sig$;" ";num2$;" = ";compute$
end function
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 




Edité par cassiope01 Le 18/05/2012 à 13h13
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 18/05/2012 à 11h21

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Salut, j'ai vu que mes modifs ne t'intérréssaient pas.
Cependant il y a un truc qui pourrait t'interresser:
Vise plutot, tout allait bien , jusqu'au moment où j'ai ajouté : "racine" et " puissance"
Losqu'on effectue une opération (quelle quelle soit), aprés avoir fait: "=", si on entre un nouveau chiffre, celui-ci vient se caler à droite (effaçant le dernier résultat)
Mais, avec "racine" et "puissance" (qui fonctionnent), si on entre un nouveau chiffre, celui-ci , n'efface pas le résultat. Alors que le rappel d'une mémoire l'éfface.
Bien que la procédure soit la meme que pour les autres opérations. What's going on ?

..........petite correction le "d" étant déjà pris , je remplace par le "a"

Code JB :
 
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar
 
  nomainwin
    WindowWidth = 245
    WindowHeight = 300
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
   STATICTEXT #calc, "z", 120, 60, 5, 15
   STATICTEXT #calc, "y", 120, 85, 5, 15
   STATICTEXT #calc, "x", 120, 110, 5, 15
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 1, 1  'Ghost window
 
    button #calc.b, "sqr", num, UL, 200, 5
    button #calc.a, "^p^", num, UL, 200, 30
     button #calc.k, "yxz", num, UL, 200, 134
     button #calc.n, "y/z", num, UL, 200, 163
     button #calc.o, "y-z", num, UL, 200, 192
     button #calc.j, "y+z", num, UL, 200, 222
      button #calc.f, "xxy", num, UL, 165, 134
      button #calc.g, "x/y", num, UL, 165, 163
      button #calc.h, "x-y", num, UL, 165, 192
      button #calc.i, "x+y", num, UL, 165, 222
    button #calc.r, "sto", num, UL, 132, 5
    button #calc.s, "sto", num, UL, 132, 30
    button #calc.u, "sto", num, UL, 132, 55
    button #calc.v, "sto", num, UL, 132, 80
      button #calc.w, "rcl", num, UL,165, 5
      button #calc.x, "rcl", num, UL,165, 30
      button #calc.y, "rcl", num, UL,165, 55
      button #calc.z, "rcl", num, UL, 165, 80
     button #calc.q, "Cm ", num, UL, 165, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 221
 
    button #calc.L, " . ", num,  UL, 5, 222
    button #calc.c, " C ", num,  UL, 132, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 122, 134
    button #calc.d, " / ", num,  UL, 122, 163
    button #calc.m, " - ", num,  UL, 122, 192
    button #calc.p, " + ", num,  UL, 122, 221
    button #calc.e, " = ", num,  UL, 83, 221
    'button #calc.q, "ent", ent,  UL, 120, 221
 
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?
 
 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
 
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
  'stockage  (début modifs "Babar")
       case n$ = "v"
          v$=disp$
          #calc.tz v$
       case n$ = "u"
          u$=disp$
          #calc.ty u$
       case n$ = "s"
          s$=disp$
          #calc.tx s$
       case n$ = "r"
          r$=disp$
          #calc.tw r$
   'recall
        case n$="z"
            num$(number)=v$
            disp$ = num$(number)
        case n$="y"
            num$(number)=u$
            disp$ = num$(number)
        case n$="x"
            num$(number)=s$
            disp$ = num$(number)
        case n$="w"
            num$(number)=r$
            disp$ = num$(number)
    ' efface box mémoires/raz var mémoires ( Cm )
       case n$ = "q"
          #calc.tw  "":r=0
          #calc.tx  "":s=0
          #calc.ty  "":u=0
          #calc.tz  "":v=0
   'opère y > z
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="k"
          num$(number) = str$(val(v$)*val(u$))
          disp$ = num$(number)
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="o"
          num$(number) = str$(val(v$)-val(u$))
          disp$ = num$(number)
       case n$="j"
          num$(number) = str$(val(v$)+val(u$))
          disp$ = num$(number)
   'opère x > y
       case n$="f"
          num$(number) = str$(val(num$(number))*val(v$))
          disp$ = num$(number)
       case n$="g"
          num$(number) = str$(val(num$(number))/val(v$))
          disp$ = num$(number)
       case n$="h"
          num$(number) = str$(val(num$(number))-val(v$))
          disp$ = num$(number)
       case n$="i"
          num$(number) = str$(val(num$(number))+val(v$))
          disp$ = num$(number)
   'racine
       case n$="b"
         num$(number) = str$(sqr(val(num$(number))))
          disp$ = num$(number)
       'case n$="b"
          'lolo=val(num$(number))
         ' num$(number) = str$(SQR(lolo))
         ' disp$ = num$(number)
   'puissance
      ' case n$="a"
      '   num$(number) = str$(val(num$(number))^^2)
      '    disp$ = num$(number)
       case n$="a"
           lili=val(num$(number))
          num$(number) = str$(lili^2)
          disp$ = num$(number)
 
 
 
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
 




Edité par Roland Le 18/05/2012 à 13h15
____________________
Roro

   
Le 18/05/2012 à 11h41

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
met result = 1 après ces opérations là.
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 18/05/2012 à 12h05

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Et voilà ce que c'est de bricoler des trucs sans savoir comment ils fonctionnent.
Tu peux enlever le "dé" et le "certant" de déconcertant. :p
Au fait, si ça te tente de raproprir ce merdier (qui fonctionne) ne te gène pas .
De mème que de montrer ça aux amerlocks (en n'oubliant pas de mentionner le nom de "Babar" l'éléphant, à la mémoire légendaire )
J'ai mis un bordel monstre dans mon dossier "font" en voulant faire un caractère en forme d'éléphant, maintenant, je répare.....Comme disait Brassens: quand on est C.. on est c... ;)



Edité par Roland Le 18/05/2012 à 12h14
____________________
Roro

   
Le 18/05/2012 à 13h05

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
C'était pas ça, y'avait un plantus: le "d " était déjà pris, ( et pour tester , je cliquais comme par hasard sur "/")je remonte corriger. Je crois que c'est tout bon .
Et voilà la rotation de la pile:

Code JB :
 
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar
 
  nomainwin
    WindowWidth = 245
    WindowHeight = 300
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
   STATICTEXT #calc, "z", 120, 60, 5, 15
   STATICTEXT #calc, "y", 120, 85, 5, 15
   STATICTEXT #calc, "x", 120, 110, 5, 15
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 1, 1  'Ghost window
 
     button #calc.§, "y->x", num, UL, 200, 80
     button #calc.£, "z->y", num, UL, 200, 55
    button #calc.b, "sqr", num, UL, 200, 5
    button #calc.a, "^p^", num, UL, 200, 30
     button #calc.k, "yxz", num, UL, 200, 134
     button #calc.n, "y/z", num, UL, 200, 163
     button #calc.o, "y-z", num, UL, 200, 192
     button #calc.j, "y+z", num, UL, 200, 222
      button #calc.f, "xxy", num, UL, 165, 134
      button #calc.g, "x/y", num, UL, 165, 163
      button #calc.h, "x-y", num, UL, 165, 192
      button #calc.i, "x+y", num, UL, 165, 222
    button #calc.r, "sto", num, UL, 132, 5
    button #calc.s, "sto", num, UL, 132, 30
    button #calc.u, "sto", num, UL, 132, 55
    button #calc.v, "sto", num, UL, 132, 80
      button #calc.w, "rcl", num, UL,165, 5
      button #calc.x, "rcl", num, UL,165, 30
      button #calc.y, "rcl", num, UL,165, 55
      button #calc.z, "rcl", num, UL, 165, 80
     button #calc.q, "Cm ", num, UL, 165, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 221
 
    button #calc.L, " . ", num,  UL, 5, 222
    button #calc.c, " C ", num,  UL, 132, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 122, 134
    button #calc.d, " / ", num,  UL, 122, 163
    button #calc.m, " - ", num,  UL, 122, 192
    button #calc.p, " + ", num,  UL, 122, 221
    button #calc.e, " = ", num,  UL, 83, 221
    'button #calc.q, "ent", ent,  UL, 120, 221
 
    open "Mini calculator" for Window as #calc
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$, trans$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?
 
 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
 
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
  'stockage  (début modifs "Babar")
       case n$ = "v"
          v$=disp$
          #calc.tz v$
       case n$ = "u"
          u$=disp$
          #calc.ty u$
       case n$ = "s"
          s$=disp$
          #calc.tx s$
       case n$ = "r"
          r$=disp$
          #calc.tw r$
   'recall
        case n$="z"
            num$(number)=v$
            disp$ = num$(number)
        case n$="y"
            num$(number)=u$
            disp$ = num$(number)
        case n$="x"
            num$(number)=s$
            disp$ = num$(number)
        case n$="w"
            num$(number)=r$
            disp$ = num$(number)
    ' efface box mémoires/raz var mémoires ( Cm )
       case n$ = "q"
          #calc.tw  "":r=0
          #calc.tx  "":s=0
          #calc.ty  "":u=0
          #calc.tz  "":v=0
   'rotation z > y
       case n$="£"
          trans$ = u$ 
          u$ = v$
          v$ = trans$ 
          #calc.tz v$
          #calc.ty u$
   'rotation y > x
       case n$="§"
          trans$ = disp$
          disp$ = v$
          v$ = trans$
          num$(number) =disp$
          #calc.tz v$
   'opère y > z
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="k"
          num$(number) = str$(val(v$)*val(u$))
          disp$ = num$(number)
       case n$="n"
          num$(number) = str$(val(v$)/val(u$))
          disp$ = num$(number)
       case n$="o"
          num$(number) = str$(val(v$)-val(u$))
          disp$ = num$(number)
       case n$="j"
          num$(number) = str$(val(v$)+val(u$))
          disp$ = num$(number)
   'opère x > y
       case n$="f"
          num$(number) = str$(val(num$(number))*val(v$))
          disp$ = num$(number)
       case n$="g"
          num$(number) = str$(val(num$(number))/val(v$))
          disp$ = num$(number)
       case n$="h"
          num$(number) = str$(val(num$(number))-val(v$))
          disp$ = num$(number)
       case n$="i"
          num$(number) = str$(val(num$(number))+val(v$))
          disp$ = num$(number)
   'racine
       case n$="b"
         num$(number) = str$(sqr(val(num$(number))))
          disp$ = num$(number)
       'case n$="b"
          'lolo=val(num$(number))
         ' num$(number) = str$(SQR(lolo))
         ' disp$ = num$(number)
   'puissance
      ' case n$="a"
      '   num$(number) = str$(val(num$(number))^^2)
      '    disp$ = num$(number)
       case n$="a"
           lili=val(num$(number))
          num$(number) = str$(lili^2)
          disp$ = num$(number)
     'fin des modifs "babar"
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
 






Edité par Roland Le 18/05/2012 à 15h53
____________________
Roro

   
Le 18/05/2012 à 19h33

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Avec répétition du dernier calcul simplement avec "=" : caractéristique qui m'a été demandée par nos amis anglophones.

Code VB :
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.)

    nomainwin
 
    global number, sign$, disp$, result, lastn$, oldnum1$, oldnum2$, oldsign$
    global calc.txt.width, calc.txt.dw, calc.txt.sw
    DIM num$(2)
    buttonSizeX = 90  'mini 38
    buttonSizeY = 50  'mini 25
    CalcPosX = 5    'position x,y if I want to include this calc in a bigger application...
    CalcPosY = 5
 
'Textbox
    textbox #calc.txt, CalcPosX+2, CalcPosY+4, 3*buttonSizeX-5, buttonSizeY-4
 
'Ghost window
    graphicbox #calc.gr, 0, 0, 1, 1
 
'Number Buttons
    button #calc.7, " 7 ", num, UL, CalcPosX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.8, " 8 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.9, " 9 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+buttonSizeY+3, buttonSizeX, buttonSizeY
    button #calc.4, " 4 ", num, UL, CalcPosX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.5, " 5 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.6, " 6 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(2*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.1, " 1 ", num, UL, CalcPosX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.2, " 2 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.3, " 3 ", num, UL, CalcPosX+2*buttonSizeX, CalcPosY+(3*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.0, " 0 ", num, UL, CalcPosX+buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'Other Buttons
    button #calc.c, " C ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+3,   buttonSizeX, buttonSizeY
    button #calc.t, " x ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+buttonSizeY+3,  buttonSizeX, buttonSizeY
    button #calc.d, " / ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(2*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.m, " - ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(3*buttonSizeY)+3,  buttonSizeX, buttonSizeY
    button #calc.p, " + ", num,  UL, CalcPosX+3*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.e, " = ", num,  UL, CalcPosX+2*buttonSizeX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
    button #calc.L, " . ", num,  UL, CalcPosX, CalcPosY+(4*buttonSizeY)+3, buttonSizeX, buttonSizeY
 
'hight and width of window
    WindowWidth = 18 + 4*buttonSizeX  '168
    WindowHeight = 44 + 5*buttonSizeY '184
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
 
'Window
    OPEN "Mini calculator" for window_nf as #calc
    #calc "trapclose [quit]"
 
'Buttons and result display
    CalcTextFont = int(buttonSizeX/4)   'scale text   depend of X size button !?
    #calc.txt "!font Times_New_Roman ";CalcTextFont
 
    digitWidth$="0 2 2 3 4 4 5 6 6 6 7 8 9 9 10 11 11 12 12 14 14 14 16 16 17 18 18 19 20 20 21 22 22 23 24 24 25 26 26 27"
    spaceWidth$="0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 12 13 13 13"
    calc.txt.width = 3*buttonSizeX-5    -30'    -30 by trial and error
    calc.txt.dw = val(word$(digitWidth$, CalcTextFont))
    calc.txt.sw = val(word$(spaceWidth$, CalcTextFont))
 
    disp$ = "0"
    #calc.txt rightJustified$(disp$)  'right justified !?  ( with font Times_New_Roman 10 )
    ButtonFontSize = int(buttonSizeY/3)    'scale buttons text  depend of Y size buttons !?
    for b = 0 to 16
        if b<10 then butt$ = "#calc."+str$(b) else butt$ = "#calc."+word$("c t d m p e L",b-9)
        #butt$ "!font Times_New_Roman ";ButtonFontSize
    next
    number = 1
 
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
function rightJustified$(text$)
    used = len(text$)*calc.txt.dw
    free = calc.txt.width - used
    rightJustified$ = space$(free/calc.txt.sw)+text$ 
   ' rightJustified$ = space$(32-len(text$)*2)+text$
end function
 
sub num handle$
    n$ = right$(handle$,1)
    select case
    case instr("0123456789",n$)>0   'numbers
        if result = 0 then num$(number) = num$(number) + n$ else num$(number) = n$
        disp$ = num$(number)
        result = 0
 
    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)     'operator
        if sign$ <> "" and val(num$(2)) <> 0 then
            disp$ = compute$(num$(1),num$(2),sign$)
            num$(1) = disp$
            num$(2) = ""
        end if
        sign$ = word$("+ - x /",instr("pmtd",n$))  'new operator
        number = 2
        result = 1
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
        result = 0
 
    case (n$ = "e" and (sign$<>"" or oldsign$<>""))  'result (" = ")
        if lastn$ = "e" then
            num$(1) = oldnum1$
            num$(2) = oldnum2$
            sign$   = oldsign$
        end if
        disp$ = compute$(num$(1),num$(2),sign$)
        num$(1) = disp$    ' go on with last result...
        oldnum1$ = num$(1)
        oldnum2$ = num$(2)
        oldsign$ = sign$
        num$(2) = ""
        sign$  = ""
        result = 1
        number = 1
 
    end select
 
    lastn$ = n$
 
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    #calc.txt rightJustified$(disp$)  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.gr "setfocus"
end sub
 
function compute$(num1$,num2$,sig$)
    select case sig$
    case "+" :compute$ = str$(val(num1$) + val(num2$))
    case "-" :compute$ = str$(val(num1$) - val(num2$))
    case "x" :compute$ = str$(val(num1$) * val(num2$))
    case "/" :compute$ = str$(val(num1$) / val(num2$))
    end select
end function
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
 
[quit]
    close #calc
end
 
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 20/05/2012 à 16h35

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Ca y est j'ai compris pourquoi la "ghost window", aprés pas mal d'éssais , il s'avère que les boutons au delà d'un certain nombre 4 à 10 déconnent quand on s'en sers pour des branchements dans une graphicbox.
Mais comme dans la calculette ils ne sont pas actifs, ça marche trés bien. Hypothèse à confire ou à infirmer.
____________________
Roro

   
Le 20/05/2012 à 16h51

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Roland:
... pourquoi la "ghost window" ...


je le dis dans le premier post, dès le départ.
Sans elle, on ne peux simplement pas capter les touches du clavier.


Roland:
il s'avère que les boutons au delà d'un certain nombre 4 à 10 déconnent quand on s'en sers pour des branchements dans une graphicbox.



???


-



Edité par cassiope01 Le 20/05/2012 à 16h55
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 20/05/2012 à 17h16

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
haaaa ! d'accord, j'avais pas capté qu'elle fonctionnait aussi au clavier. Décidement elle a les dents en or cette calculette.
Par contre, je trouve étonnant que le gars qui la faite,( c'est toi avec d'autres à ce que j'ai compris) et qui a du cogitter un tantinet plus que l'apparence anodine qu'elle offre au regard.
Je trouve donc étonnant qu'ils n'aient pas pensé à ajouter les quelques lignes qui transforment le couteau à beurre en couteau de chasse.
Je ne sais pas si tu te sers souvent de ce types d'outil, j'en ai une floppée sur mon disque, et bien je peux t'affirmer que sur tout le net tu ne trouvera une seule calculatrice avec une pile à permutations.
C"est vraiment dommage que j'ai codé ça comme un porc. Mais que veux -tu...c'est la frénésie....
____________________
Roro

   
Le 20/05/2012 à 17h52

Libertynaute Expert

Groupe: Membre

Inscrit le: 19/02/2011
Messages: 767
Cette calculette simple était destiné à un Australien afin qu'il puisse l'utiliser au sain de ses prog de jeux.

Sinon tu as Calc7List .


-



Edité par cassiope01 Le 20/05/2012 à 17h52
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."

Web    
Le 20/05/2012 à 18h13

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
ha, celle là, je ne l'avais pas. ...je l'ajoute à ma collection...Merci l'ami. ;)
____________________
Roro

   
Le 18/09/2013 à 01h41

Administrateur

Groupe: Administrateur

Inscrit le: 04/03/2012
Messages: 2083
Bon ben, la calculette simple est devenue compliquée:
8 mémoires dont 4 avec possibilité de commentaires associés

Code VB :
 
 
' By Cassiope01 with the precious help of NJames and tsh73.
' http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1335604139&start=0#1335676038
' (started from "calc.bas" by Joshua Morgan.) Memory added by: Babar

  nomainwin
    WindowWidth = 590 '250
    WindowHeight = 295
    UpperLeftX = (DisplayWidth-WindowWidth) / 4
    UpperLeftY = (DisplayHeight-WindowHeight) / 4
    global com$
 
   STATICTEXT #calc, "s", 120, 35, 5, 15
   STATICTEXT #calc, "z", 120, 60, 5, 15
   STATICTEXT #calc, "y", 120, 85, 5, 15
   STATICTEXT #calc, "x", 120, 110, 5, 15
    textbox #calc.tw, 5, 5, 110, 25
    textbox #calc.tx, 5, 30, 110, 25
    textbox #calc.ty, 5, 55, 110, 25
    textbox #calc.tz, 5, 80, 110, 25
  textbox #calc.txt, 5, 105, 110, 25
 
    graphicbox #calc.gr, 0, 0, 120, 220  'ex Ghost window
    graphicbox #calc.gs, 128, 0, 71, 135 'mémoires
    graphicbox #calc.gq, 200, 0, 40, 55 'sqr p
    graphicbox #calc.gt, 160, 136, 76, 120 'opérat mémoires
    graphicbox #calc.gu, 122, 136, 35, 120 'opérat
    graphicbox #calc.gv, 79, 220, 42, 36 '=
    graphicbox #calc.gw, 40, 220, 39, 36 'zéro
    graphicbox #calc.gp, 0, 220, 40, 36 'point

 
     button #calc.%, "s->z", num, UL, 200, 55
     button #calc.£, "z->y", num, UL, 200, 80
     button #calc.§, "y->x", num, UL, 200, 108
    button #calc.b, "sqr", num, UL, 205, 5
    button #calc.a, "^p^", num, UL, 205, 30
     button #calc.k, "zxy", num, UL, 200, 139'134
     button #calc.n, "z/y", num, UL, 200, 168'163
     button #calc.o, "z-y", num, UL, 200, 197'192
     button #calc.j, "z+y", num, UL, 200, 227'222
      button #calc.f, "yxx", num, UL, 165, 139'134
      button #calc.g, "y/x", num, UL, 165, 168'163
      button #calc.h, "y-x", num, UL, 165, 197'192
      button #calc.i, "y+x", num, UL, 165, 227'222
    button #calc.r, "sto", num, UL, 132, 5
    button #calc.s, "sto", num, UL, 132, 30
    button #calc.u, "sto", num, UL, 132, 55
    button #calc.v, "sto", num, UL, 132, 80
      button #calc.w, "rcl", num, UL,165, 5
      button #calc.x, "rcl", num, UL,165, 30
      button #calc.y, "rcl", num, UL,165, 55
      button #calc.z, "rcl", num, UL, 165, 80
  '-------------------------------------------------------------------
  button #calc.fw, "<-Transf", mem, UL,240, 5, 50, 25
  button #calc.fx, "<-Transf", mem, UL,240, 30, 50, 25
  button #calc.fy, "<-Transf", mem, UL,240, 55, 50, 25
  button #calc.fz, "<-Transf", mem, UL,240, 80, 50, 25
    button #calc.mr, "sto", mem, UL, 290, 5
    button #calc.ms, "sto", mem, UL, 290, 30
    button #calc.mu, "sto", mem, UL, 290, 55
    button #calc.mv, "sto", mem, UL, 290, 80
    textbox #calc.mw, 323, 5, 110, 25
    textbox #calc.mx, 323, 30, 110, 25
    textbox #calc.my, 323, 55, 110, 25
    textbox #calc.mz, 323, 80, 110, 25
   STATICTEXT #calc.str, "---------------------------------------------", 440, 10, 150, 15
   STATICTEXT #calc.sts, "---------------------------------------------", 440, 35, 150, 15
   STATICTEXT #calc.stu, "---------------------------------------------", 440, 60, 150, 15
   STATICTEXT #calc.stv, "---------------------------------------------", 440, 85, 150, 15 'opqrstuvwxyz
   STATICTEXT #calc.stcom, "Commentaire:", 245, 210, 100, 15
   textbox #calc.com, 245, 227, 150, 25
  '----------------------------------------------------------------------
     button #calc.q, "Cm ", num, UL, 165, 108
 
    button #calc.7, " 7 ", num, UL,  5, 134  'Number Buttons
    button #calc.8, " 8 ", num, UL, 44, 134
    button #calc.9, " 9 ", num, UL, 83, 134
    button #calc.4, " 4 ", num, UL,  5, 163
    button #calc.5, " 5 ", num, UL, 44, 163
    button #calc.6, " 6 ", num, UL, 83, 163
    button #calc.1, " 1 ", num, UL,  5, 192
    button #calc.2, " 2 ", num, UL, 44, 192
    button #calc.3, " 3 ", num, UL, 83, 192
    button #calc.0, " 0 ", num, UL, 44, 226
 
    button #calc.L, " . ", num,  UL, 5, 226
    button #calc.c, " C ", num,  UL, 132, 108 'Other Buttons
    button #calc.t, " x ", num,  UL, 124, 139'134
    button #calc.d, " / ", num,  UL, 124, 168'163
    button #calc.m, " - ", num,  UL, 124, 197'192
    button #calc.p, " + ", num,  UL, 124, 226'221
    button #calc.e, " = ", num,  UL, 83, 226
    'button #calc.q, "ent", ent,  UL, 120, 221

    open "Mini calculator" for Window as #calc
    #calc.gr "down"
    #calc.gr "fill black"
    #calc.gs "fill pink"
    #calc.gt "fill blue"
    #calc.gu "fill cyan"
    #calc.gv "fill yellow"
    #calc.gw "fill black"
    #calc.gq "fill cyan"
    #calc.gp "fill brown"
    #calc "trapclose [quit]"
    #calc.txt "!font Times_New_Roman 10"
 
    global number, sign$, disp$, res$, result
    global z$, y$, x$, w$, v$, u$, r$, s$, trans$
 
    DIM num$(2)
 
    number = 1
    disp$ = "0"
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?

 
    #calc.txt disp$
    #calc.gr "setfocus"
    #calc.gr "when characterInput [key]"
wait
 
sub num handle$
    n$ = right$(handle$,1)
    select case
 
    case instr("0123456789",n$)>0   'numbers
        num$(number) = num$(number) + n$
        if result then num$(number) = n$
        disp$ = num$(number)
       ' res$ = disp$
        result = 0
  'stockage  (début modifs "Babar")
       case n$ = "v"
          v$=disp$
          #calc.tz v$
       case n$ = "u"
          u$=disp$
          #calc.ty u$
       case n$ = "s"
          s$=disp$
          #calc.tx s$
       case n$ = "r"
          r$=disp$
          #calc.tw r$
   'recall
        case n$="z"
            num$(number)=v$
            disp$ = num$(number)
        case n$="y"
            num$(number)=u$
            disp$ = num$(number)
        case n$="x"
            num$(number)=s$
            disp$ = num$(number)
        case n$="w"
            num$(number)=r$
            disp$ = num$(number)
    ' efface box mémoires/raz var mémoires ( Cm )
       case n$ = "q"
          #calc.tw  "":r=0
          #calc.tx  "":s=0
          #calc.ty  "":u=0
          #calc.tz  "":v=0
   'rotation s > z
       case n$="%"
          trans$ = s$ 
          s$ = u$
          u$ = trans$ 
          #calc.tx s$
          #calc.ty u$
   'rotation z > y
       case n$="£"
          trans$ = u$ 
          u$ = v$
          v$ = trans$ 
          #calc.tz v$
          #calc.ty u$
   'rotation y > x
       case n$="§"
          trans$ = disp$
          disp$ = v$
          v$ = trans$
          num$(number) =disp$
          #calc.tz v$
   'opère y > z
       case n$="n"
          num$(number) = str$(val(u$)/val(v$))
          disp$ = num$(number)
       case n$="k"
          num$(number) = str$(val(v$)*val(u$))
          disp$ = num$(number)
       case n$="o"
          num$(number) = str$(val(u$)-val(v$))
          disp$ = num$(number)
       case n$="j"
          num$(number) = str$(val(v$)+val(u$))
          disp$ = num$(number)
   'opère x > y
       case n$="f"
          num$(number) = str$(val(num$(number))*val(v$))
          disp$ = num$(number)
       case n$="g"
          num$(number) = str$(val(v$)/val(num$(number)))
          disp$ = num$(number)
       case n$="h"
          num$(number) = str$(val(v$)-val(num$(number)))
          disp$ = num$(number)
       case n$="i"
          num$(number) = str$(val(num$(number))+val(v$))
          disp$ = num$(number)
   'racine
       case n$="b"
         num$(number) = str$(sqr(val(num$(number))))
          disp$ = num$(number)
       'case n$="b"
          'lolo=val(num$(number))
         ' num$(number) = str$(SQR(lolo))
         ' disp$ = num$(number)
   'puissance
      ' case n$="a"
      '   num$(number) = str$(val(num$(number))^^2)
      '    disp$ = num$(number)
       case n$="a"
           lili=val(num$(number))
          num$(number) = str$(lili^2)
          disp$ = num$(number)
    'fin des modifs "babar"

    case n$ = "L"               'decimal
        if len(num$(number)) = 0 then num$(number) = "0."
        if instr(num$(number),".") = 0 then num$(number) = num$(number) + "."
        disp$ = num$(number)
        result = 0
 
    case (instr("pmtd",n$)>0) and (val(num$(1)) <> 0)
        sign$ = word$("+ - x /",instr("pmtd",n$))   'operator
        if val(num$(1))<>0 and val(num$(2))<>0 then [res]
        number = 2
 
    case n$ = "c"             'reset
        disp$ = "0"
        sign$ = ""
        redim num$(2)
        number = 1
 
    case (n$ = "e") and (sign$ <> "")   'result (" = ")
        #calc.com,"" 'vide le commentaire
        [res]
        select case sign$
        case "+" :res$ = str$(val(num$(1)) + val(num$(2)))
        case "-" :res$ = str$(val(num$(1)) - val(num$(2)))
        case "x" :res$ = str$(val(num$(1)) * val(num$(2)))
        case "/" :res$ = str$(val(num$(1)) / val(num$(2)))
        end select
        disp$ = res$
        sign$ = ""
        redim num$(2)
        number = 1
        num$(number) = res$    ' go on with last result...
        result = 1
 
    end select
    if instr(disp$,".")=0 then  'to erase first "0"
        if (val(disp$)<>0 and left$(disp$,1)="0") then disp$ = str$(val(disp$))
    end if
    disp$ = space$(32-len(disp$)*2)+disp$  'right justified !?  ( with font Times_New_Roman 10 )
    #calc.txt disp$
    #calc.gr "setfocus"
end sub
 
[key]
    key$=Inkey$
    select case
    case instr("+-*/.",key$)>0
        key$ = word$("p m t d L",instr("+-*/.",key$))
    case key$ = CHR$(13)
        key$="e"
    case key$ = CHR$(27)
        key$="c"
    case instr("0123456789",key$)=0
        goto [out]
    end select
    call num "#calc.";key$
    [out]
wait
sub mem handle$ '---- memoires de droite avec commentaires
    m$ = right$(handle$,2)
    select case
       case m$ = "mv" '----stockage
          mv$=disp$
          #calc.mz mv$:call com
          #calc.stv,com$
       case m$ = "mu"
          mu$=disp$
          #calc.my mu$:call com
          #calc.stu,com$
       case m$ = "ms"
          ms$=disp$
          #calc.mx ms$:call com
          #calc.sts,com$
       case m$ = "mr"
          mr$=disp$
          #calc.mw mr$:call com
          #calc.str,com$
 
        case m$="fz" '---Transfert
            #calc.mz, "!contents? mv$"
            #calc.tz, mv$:v$=mv$
        case m$="fy"
            #calc.my, "!contents? my$"
            #calc.ty, my$:u$=my$
        case m$="fx"
            #calc.mx, "!contents? mx$"
            #calc.tx, mx$:s$=mx$
        case m$="fw"
            #calc.mw, "!contents? mw$"
            #calc.tw, mw$:r$=mw$
    end select
end sub
sub com
   #calc.com, "!contents? com$"
end sub
[quit]
    close #calc
end
 
 
____________________
Roro

   
Général » Petite calculatrice très simple. Fonctionne à la souris ou/et au clavier.  

 |  |

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