Solved

quick and easy one..

Posted on 2004-04-09
1
136 Views
Last Modified: 2010-04-05
is there a method in delphi that returns the index of the element that holds the highest value in an array`?
0
Comment
Question by:Darth_helge
1 Comment
 
LVL 6

Accepted Solution

by:
rbohac earned 125 total points
ID: 10795800
no. You will have to loop through the entire array to find the highest value.

var x,idx,HighValue:Integer;
begin
idx := -1;
HighValue := Low(Integer);
for x:=low(myarray) to high(myarray) do
  if myarray[x] > HighValue then
    begin
      HighValue := myarray[x] ;
      idx :=x;
    end;

ShowMessage('Highest value is at index '+IntToStr(idx));
end;
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now