in labels scrivi:
Carote 550,00 Patate 750,00
in data invece:
550.00 750.00
come vedi in Labels (ciò che vedrai stampato a video) ho inserito il numero con la virgola.
In data invece il separatore è il .
quindi al frame associa questo (in questo esempio ho dato come nome istanza ai 3 listBox lista1 lista2 lista3 mentre il campo di testo ha come nome di istanza totale);
codice:
function virgola(Num){
a = Num.toString().split('.');
if(!a[1])
tot = a[0] +",00";
else
if(a[1] < 10)
tot = a[0] + "," + a[1] + "0";
else
tot = a[0] + "," + a[1];
}
puls.onRelease = function(){
list1 = lista1.getSelectedItem().label;
list2 = lista2.getSelectedItem().label;
list3 = lista3.getSelectedItem().label;
totale.text = list1 + "\n" + list2 + "\n" + list3;
totList1 = lista1.getSelectedItem().data;
totList2 = lista2.getSelectedItem().data;
totList3 = lista3.getSelectedItem().data;
somma = totList1 + totList2 + totList3;
virgola(somma);
totale.text = totale.text + "\n\nTotale --> " + tot;
}
Il pulsante per calcolare il tutto ha come nome istanza puls
Se non ti è chiaro qualcosa dimmi pure