Douglas Farias Expert Licensed User Longtime User Sep 30, 2014 #1 Hi all what the best way, correct to make this code in b4a? B4X: For i = 1 to 31 spdia.Add(i < 10 ? "0".concat(i) : i); next i made B4X: For i = 1 To 31 If i < 10 Then spdia.Add(0&i) Else spdia.Add(i) End If Next but have a way to make this with tenary, 1 line? as Experienced programmers as you simplify this code?
Hi all what the best way, correct to make this code in b4a? B4X: For i = 1 to 31 spdia.Add(i < 10 ? "0".concat(i) : i); next i made B4X: For i = 1 To 31 If i < 10 Then spdia.Add(0&i) Else spdia.Add(i) End If Next but have a way to make this with tenary, 1 line? as Experienced programmers as you simplify this code?
thedesolatesoul Expert Licensed User Longtime User Sep 30, 2014 #2 B4X: For i = 1 to 31 spdia.Add(NumberFormat(i,2,0)) Next sorry no ternary from me Upvote 0
Douglas Farias Expert Licensed User Longtime User Sep 30, 2014 #3 have another way ? xD only curious xD Upvote 0
S sorex Expert Licensed User Longtime User Sep 30, 2014 #4 in case you want it to work with strings aswell you could use B4X: For i = 1to31 t="000"&i spdia.Add( t.SubString(t.Length-3) ) Next this one would work from 000-999 (didn't try this code tho but I use this method for over a decade in other languages) Upvote 0
in case you want it to work with strings aswell you could use B4X: For i = 1to31 t="000"&i spdia.Add( t.SubString(t.Length-3) ) Next this one would work from 000-999 (didn't try this code tho but I use this method for over a decade in other languages)
Douglas Farias Expert Licensed User Longtime User Sep 30, 2014 #5 and logic question its possible make a major to minor number at for? B4X: for i = 2014 to 1990 log(i) next its possible make this? Upvote 0
and logic question its possible make a major to minor number at for? B4X: for i = 2014 to 1990 log(i) next its possible make this?
thedesolatesoul Expert Licensed User Longtime User Sep 30, 2014 #7 for i = 2014 to 1990 Step -10 Upvote 0
Douglas Farias Expert Licensed User Longtime User Sep 30, 2014 #8 really thx man, i m learned this now Upvote 0
Daestrum Expert Licensed User Longtime User Sep 30, 2014 #9 look at this post http://www.b4x.com/android/forum/threads/iif.15363/#post-87141 Upvote 0