Elric Well-Known Member Licensed User May 31, 2021 #1 I'm trying to implement time in a B4XPlusMinus, like this: hours and minutes together. I looked for setting SetNumericRange but without success. So, I used a workaround: B4X: Private TimeList As List (...) TimeList.Initialize For j = 0 To 23 For k = 0 To 59 TimeList.Add($"$1.0{j}:$2.0{k}"$) Next Next (...) B4XPlusMinus1.SetStringItems(TimeList) that works perfectly. But this sound to me as smelling code. I wonder if there is a way with SetNumericRange or another way that doesn't involve two For cycle and a list.
I'm trying to implement time in a B4XPlusMinus, like this: hours and minutes together. I looked for setting SetNumericRange but without success. So, I used a workaround: B4X: Private TimeList As List (...) TimeList.Initialize For j = 0 To 23 For k = 0 To 59 TimeList.Add($"$1.0{j}:$2.0{k}"$) Next Next (...) B4XPlusMinus1.SetStringItems(TimeList) that works perfectly. But this sound to me as smelling code. I wonder if there is a way with SetNumericRange or another way that doesn't involve two For cycle and a list.
William Lancee Well-Known Member Licensed User Longtime User May 31, 2021 #2 Time is of course a continuum. Numeric range of Time of day is 0 to 1439 minutes. But B4XFormatter can't convert minutes to hours and mins. So your approach seems OK to me. Remember that if you make TimeList a global it only needs to be done once in the whole App and execution time is negligible. Upvote 0
Time is of course a continuum. Numeric range of Time of day is 0 to 1439 minutes. But B4XFormatter can't convert minutes to hours and mins. So your approach seems OK to me. Remember that if you make TimeList a global it only needs to be done once in the whole App and execution time is negligible.
Elric Well-Known Member Licensed User Jun 1, 2021 #4 That's means that my code smell no so much! I will use TimeList as global! Thank you! Upvote 0