tufanv Expert Licensed User Longtime User Mar 31, 2014 #1 Hello I have 10 integers. I need an advice to get the 4 biggest value from this set of integers. TY
thedesolatesoul Expert Licensed User Longtime User Mar 31, 2014 #2 Is it in an array? You can add them all to a list. Do Sort, and pick the first item. Upvote 0
DonManfred Expert Licensed User Longtime User Mar 31, 2014 #3 Code: Copy 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 9 7 5 2 Click to expand... Tags: sort array Edit: Arg, too slow Last edited: Mar 31, 2014 Upvote 0
Code: Copy 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 9 7 5 2 Click to expand... Tags: sort array Edit: Arg, too slow
stevel05 Expert Licensed User Longtime User Mar 31, 2014 #5 @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 Mar 31, 2014 #7 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
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
DonManfred Expert Licensed User Longtime User Mar 31, 2014 #8 Code: Copy label(v) = cursorraces.GetString("car"&v) Upvote 0
klaus Expert Licensed User Longtime User Mar 31, 2014 #9 If you have only carX columns you could use Code: Copy label(v) = cursorraces.GetString2(v) You could also use a For / Next loop instead of a Do While / Loop loop no need for v=v+1. Upvote 0
If you have only carX columns you could use Code: Copy label(v) = cursorraces.GetString2(v) You could also use a For / Next loop instead of a Do While / Loop loop no need for v=v+1.
tufanv Expert Licensed User Longtime User Mar 31, 2014 #10 DonManfred said: Code: Copy label(v) = cursorraces.GetString("car"&v) Click to expand... already tried . It gives an error Upvote 0
DonManfred said: Code: Copy label(v) = cursorraces.GetString("car"&v) Click to expand... already tried . It gives an error
tufanv Expert Licensed User Longtime User Mar 31, 2014 #11 klaus said: If you have only carX columns you could use Code: Copy label(v) = cursorraces.GetString2(v) You could also use a For / Next loop instead of a Do While / Loop loop no need for v=v+1. Click to expand... 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
klaus said: If you have only carX columns you could use Code: Copy label(v) = cursorraces.GetString2(v) You could also use a For / Next loop instead of a Do While / Loop loop no need for v=v+1. Click to expand... 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 !
klaus Expert Licensed User Longtime User Mar 31, 2014 #12 When using label(v) = cursorraces.GetString("car"&v) what error do you get ? For me it should work. Upvote 0
tufanv Expert Licensed User Longtime User Mar 31, 2014 #13 you are right it works ! Ty both for help ! Upvote 0