ListBox Position lazarus / 61-Beginners ---------------------------------------------------------------------- pentilisea · 2023-02-27 09:53 Hi Guys, back again with a stupid question. Even though I googled it, I'm not getting a positive result. I need tp pass the last Item of a ListBox (a number, not nessesarily an Integer) into a Variable or better into a Edit.Box or Label. I managed to select last Item, but failed to pass it further. First item also would be an option. I only managed to pass the number of items.. Please look at my code here and correct it. Sorry for the inconveniance ..... xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx procedure TForm1.Button1Click(Sender: TObject);   var iTest: Integer;       gesamt: Integer; begin   ListBox1.Clear;   OpenDialog1.Filter:='txt-Dateien|*.txt';   if OpenDialog1.Execute then   ListBox1.Items.LoadFromFile(OpenDialog1.Filename);   for i:=ListBox1.Items.Count - 1 downto 0 do         if not TryStrToInt(ListBox1.Items, iTest) then         ListBox1.Items.Delete(i);   ListBox1.ItemIndex := ListBox1.Items.Count-1;   ListBox1.ClearSelection;   ListBox1.Selected[ListBox1.Count-1] := TRUE;     gesamt:= ListBox1.ItemIndex;     Edit1.Text := ListBox1.ItemIndex.ToString;    Label1.Caption := OpenDialog1.Filename; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Thanks Klaus ---------------------------------------------------------------------- KodeZwerg · 2023-02-27 10:29 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Label1.Caption := ListBox1.Items.Strings[Pred(ListBox1.Count)]; ---------------------------------------------------------------------- KodeZwerg · 2023-02-27 10:34 Please put your code into [ code ] mycode [ /code ] tags by pressing [ # ] button, thanks. ---------------------------------------------------------------------- pentilisea · 2023-02-28 19:05 Hi Zwerg, thanks so much. I will try to adhere to the code thing next time. What stands "Pred" for? Klaus ---------------------------------------------------------------------- paweld · 2023-02-28 19:32 -1  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Label1.Caption := ListBox1.Items.Strings[ListBox1.Count - 1]; ---------------------------------------------------------------------- KodeZwerg · 2023-02-28 19:50 Quote from: pentilisea on February 28, 2023, 08:05:17 pmHi Zwerg, thanks so much. I will try to adhere to the code thing next time. What stands "Pred" for? Klaus In math like paweld wrote, in words Pred() means Predecessor. (-1) The opposite would be Succ() for Successor. (+1) ---------------------------------------------------------------------- cdbc · 2023-03-02 19:03 Hi TListbox has a Caption property... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...ListBox1.ItemIndex := ListBox1.Items.Count-1;...Label1.Caption := ListBox1.Caption; // when you set itemindex you get its text in caption... Hth - Regards Benny