Not sure if this is a bug or not, but here's what I found:
I have a sub that loads a record from a database. The sub is pretty standard & has a query to get the record I'm looking for & then loads the various fields into views. In the process of doing this, it formats a couple of numbers (an appttime field into a ##:## format & a cost field into a #.## format). The first formatting looks like this:
& the second formatting looks like this:
(Don't ask me why I use 2 different ways of formatting - I just do)
After the activity loads & the first time I call this sub to load a record, it all works fine. Eg: if the time being formatted is 11:45AM, then it will be shown as "11:45". However, the second & subsequent times I call this sub, the time will be shown as "11.00:45.00". If I comment out the second formatting line (the one that uses NumberFormat2) then it all works fine. Also, if I change the first formatting line to:
then it all works fine as well.
It seems that the NumberFormat2 is somehow creating some persistent format that is overriding the $"$2... "$ formatting I am trying to use. It's easy enough to work around by just using NumberFormat instead of the way I initially did it, but still seems odd to me.
- Colin.
I have a sub that loads a record from a database. The sub is pretty standard & has a query to get the record I'm looking for & then loads the various fields into views. In the process of doing this, it formats a couple of numbers (an appttime field into a ##:## format & a cost field into a #.## format). The first formatting looks like this:
B4X:
txtApptTime.Text = $"$2{DateTime.GetHour(mRec.get("appttime"))}:$2{DateTime.GetMinute(mRec.get("appttime"))}"$
& the second formatting looks like this:
B4X:
txtCost.Text = NumberFormat2(mRec.Get("cost"), 1, 2, 2, False)
(Don't ask me why I use 2 different ways of formatting - I just do)
After the activity loads & the first time I call this sub to load a record, it all works fine. Eg: if the time being formatted is 11:45AM, then it will be shown as "11:45". However, the second & subsequent times I call this sub, the time will be shown as "11.00:45.00". If I comment out the second formatting line (the one that uses NumberFormat2) then it all works fine. Also, if I change the first formatting line to:
B4X:
txtApptTime.Text = NumberFormat(DateTime.GetHour(mRec.get("appttime")), 2, 0) & ":" & NumberFormat(DateTime.GetMinute(mRec.get("appttime")), 2, 0)
then it all works fine as well.
It seems that the NumberFormat2 is somehow creating some persistent format that is overriding the $"$2... "$ formatting I am trying to use. It's easy enough to work around by just using NumberFormat instead of the way I initially did it, but still seems odd to me.
- Colin.