Android Question select biggest value from 10 different int.

tufanv

Expert
Licensed User
Longtime User
Hello

I have 10 integers. I need an advice to get the 4 biggest value from this set of integers.

TY
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim A() As Int
A = Array As Int(5, 7, 1, 2, 9, 2)
Dim L As List
L.Initialize
L.AddAll(A)
L.Sort(False)
For i = 0 To 3
  Log(L.Get(i))
Next


Tags: sort array

Edit: Arg, too slow
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
@DonManfred That would make a good entry in the code snippets forum, or add tags to this post.

Steve
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I have one more question. I have car0 car1 car2 car3 ... car19 as coloumns in a sql db in a single row. I want to use cursor.getstring("car0") and same for all the rest until car19 ( ı have to take values from db).

I am planning to use "do while" but i cant figure out how to use it with do while and getstring

for example :
i use this code until v=20 :
dim v as int = 0
do while v<20
label(v) = cursorraces.GetString(car(v))
V=v+1
loop


but when i use this it search for the coloumn car(1) instead of car1 so cant find the coloumn and cant get the value.
I tried to ask this question bfore but couldnt get a clear answer where am i doing wrong.

ty
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User

It seems like working . I dont have onlu car0 car1... in coloumns but i think with adjusting v value i will be able to do. Thanks !
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…