Code Snippet: electricity price consumption calculator

no Code Snippet category here?

i used this to see what my mac mini cost each month as database server :slight_smile:

Xojo 2019r3.1
it need a Window with TextWatt,TextPrice,Listbox1 with 2 columns and a Button

Var watt As Double = Double.FromString(TextWatt.Value,Locale.Current)

Listbox1.RemoveAllRows

Var price As Double = Double.FromString(TextPrice.Value,Locale.Current)

'365 days a year
Const monthDays = 365.0 / 12.0

Var hour As Double = (watt / 1000.0) * price
Var day As Double = hour * 24.0
Var month As Double  = day * monthDays
Var monthday8 As Double  = (day / 3.0) * monthDays

Listbox1.AddRow "hour",hour.ToString(Locale.Current) + " " + Locale.Current.CurrencySymbol
Listbox1.AddRow "day",day.ToString(Locale.Current) + " " + Locale.Current.CurrencySymbol
Listbox1.AddRow "month",month.ToString(Locale.Current) + " " + Locale.Current.CurrencySymbol
Listbox1.AddRow "month each 8 hours a day",monthday8.ToString(Locale.Current) + " " + Locale.Current.CurrencySymbol

Snap_2020.08.17_11h16m18s_001_