M micro Well-Known Member Licensed User Longtime User Jul 14, 2015 #1 Hi to all why NumberFormat not work? Code: Copy Dim f As Double = 60 / (DateTime.TimeParse(oraattuale) - DateTime.TimeParse(orapemem)) / 1000 mediaminuto = NumberFormat(f, 1, 1).Replace(".", ",") The result in f is correct but mediaminuto is always 0,0
Hi to all why NumberFormat not work? Code: Copy Dim f As Double = 60 / (DateTime.TimeParse(oraattuale) - DateTime.TimeParse(orapemem)) / 1000 mediaminuto = NumberFormat(f, 1, 1).Replace(".", ",") The result in f is correct but mediaminuto is always 0,0
DonManfred Expert Licensed User Longtime User Jul 14, 2015 #2 What is the value of oraattuale and orapemem ? Upvote 0
M micro Well-Known Member Licensed User Longtime User Jul 14, 2015 #3 oraattuale always > of orapemem example "10:12:02" and "10:12:33" but repeat, the value in f is correct. Upvote 0
oraattuale always > of orapemem example "10:12:02" and "10:12:33" but repeat, the value in f is correct.
LucaMs Expert Licensed User Longtime User Jul 14, 2015 #4 Non mi sembra corretta f; tu vuoi ottenere una media al minuto, quindi devi dividere il tempo trascorso per 60000. Inoltre, ti serve tutto in formato stringa? Normalmente è meglio usare i Long: oraattuale = DateTime.Now I think f shoud be: Dim f As Double = (DateTime.TimeParse(oraattuale) - DateTime.TimeParse(orapemem)) / 60000 ' Do you need orapemem be a string? Can you not use a Long like StartTime = DateTime.Now? Also, you should not use that Replace (eventually, you should use AHNumeric in AHLocale library) Anyway, what is the log of: log(NumberFormat(f, 1, 1)) ? Last edited: Jul 14, 2015 Upvote 0
Non mi sembra corretta f; tu vuoi ottenere una media al minuto, quindi devi dividere il tempo trascorso per 60000. Inoltre, ti serve tutto in formato stringa? Normalmente è meglio usare i Long: oraattuale = DateTime.Now I think f shoud be: Dim f As Double = (DateTime.TimeParse(oraattuale) - DateTime.TimeParse(orapemem)) / 60000 ' Do you need orapemem be a string? Can you not use a Long like StartTime = DateTime.Now? Also, you should not use that Replace (eventually, you should use AHNumeric in AHLocale library) Anyway, what is the log of: log(NumberFormat(f, 1, 1)) ?
M micro Well-Known Member Licensed User Longtime User Jul 15, 2015 #5 Yes, oraattuale and orapemem are string. you're right, it's easier to divide to 60000 and not in two steps (are test to get the first results in seconds) In b4j work fine, i reported bad the code, that 1000 should be in parentheses..... Appena posso correggo e riprovo Thanks Upvote 0
Yes, oraattuale and orapemem are string. you're right, it's easier to divide to 60000 and not in two steps (are test to get the first results in seconds) In b4j work fine, i reported bad the code, that 1000 should be in parentheses..... Appena posso correggo e riprovo Thanks
M micro Well-Known Member Licensed User Longtime User Jul 15, 2015 #6 this is the right code Code: Copy Dim f As Double = 60 / ((DateTime.TimeParse(oracompleta) - DateTime.TimeParse(orapesomem)) / 1000) Dim s As String = NumberFormat(f, 1, 1) mediaminuto = s.Replace(".", ",") Is incorrect / 60000. Upvote 0
this is the right code Code: Copy Dim f As Double = 60 / ((DateTime.TimeParse(oracompleta) - DateTime.TimeParse(orapesomem)) / 1000) Dim s As String = NumberFormat(f, 1, 1) mediaminuto = s.Replace(".", ",") Is incorrect / 60000.
LucaMs Expert Licensed User Longtime User Jul 15, 2015 #7 Yes, you're right. If you want your app works "everywhere", you should not use that replacement. Upvote 0
LucaMs Expert Licensed User Longtime User Jul 15, 2015 #8 https://www.b4x.com/android/forum/threads/numberformat-locals.11338/ Upvote 0