Combobox Tobject lazarus / 21-General ---------------------------------------------------------------------- SteenJorgensen · 2025-06-29 09:27 I use to find my index in a combobox from sql like:     ComboBox.ItemIndex := ComboBox.Items.IndexOfObject(TObject(Que.Fie ldByName('koretoj').AsInteger)); But after compiling in 64bit i get this: umain.pas(591,58) Error: Illegal type conversion: "LongInt" to "TObject" Hint???? ---------------------------------------------------------------------- jamie · 2025-06-29 09:45 Maybe you are looking for index of and not index of object ---------------------------------------------------------------------- SteenJorgensen · 2025-06-29 09:45 Please tell my where? I think that it's a incorrect type??? ---------------------------------------------------------------------- SteenJorgensen · 2025-06-29 09:50 I have a tobject in my combobox for all text, set as:        ComboBox.Items.AddObject(Que.FieldByName('navn').AsString, TObject(Pointer(Que.FieldByName('id').AsInteger))); And then i want to find the index via object when i make a query. ---------------------------------------------------------------------- cdbc · 2025-06-29 09:54 Hi Your problem stems from the fact, that in 64bit systems an 'integer' = 'longint' = 4 bytes, it gets setup when you define {$mode objfpc}, whereas the 'TObject' behind the scenes, is a pointer, which in 64bit terms means 8 bytes!!! (NOTE: this mismatch will happen to THandles too!) So what you need to do, is this: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 ComboBox.ItemIndex := ComboBox.Items.IndexOfObject(TObject(Que.FieldBy Name('koretoj').AsLargeInt));'AsLargeInt' is defined as returning an 'int64', which ofc. is 64bit/8 bytes(but do not do pointer-math on it!!!) BTW, You should get used to using 'PtrInt' instead of 'integer' & 'PtrUInt' instead of 'Cardinal'. The reason for this is, they are aliases for the platform-specific "pointer-sized" integer/longword(cardinal), which means, on 32bit systems they're 4 bytes integers & on 64bit systems they're 8 bytes integers...  HTH Regards Benny Ps.: Hvis du vil ha' hele smøren på dansk, så bare sig til ---------------------------------------------------------------------- cdbc · 2025-06-29 10:05 Hi again... OHhh, I almost forgot, you ofc. will have to change your saving-to-db code too, 'cause they'll be saved as 4 byte integers, which are of no use to you now... OFC, I'm now wondering what will happen to your already stored data in db?!? ...if they're all 4 byte integers, "Oh Crap!" MeThinks your architecture is "Up Shit Creek, without a paddle"  Regards Benny ---------------------------------------------------------------------- jamie · 2025-06-29 10:33 I would say you have a serious design problem more of that later ---------------------------------------------------------------------- SteenJorgensen · 2025-06-29 10:45 Hej Benny Mange tak for tilbagemeldning. Kan godt se problemet og nu spiller det sku bare. TAK. Mvh Steen ---------------------------------------------------------------------- jamie · 2025-06-29 10:59 You are using pointers as integers in 32-bit mode they are the same size as integers and 64-bit mode they are twice the size and not compatible. you need to type cast using the pointer integer around it to convert it ---------------------------------------------------------------------- Thaddy · 2025-06-29 11:01 The tag property has changed: It is now a PtrUint, so can store the native pointer size for the platform. It it is no longer a 32 bit integer type. Some Laz versions may still declare it as PtrInt, but that was a mistake. See: https://www.freepascal.org/docs-html/rtl/system/ptrint.html ---------------------------------------------------------------------- cdbc · 2025-06-29 11:17 Hey Steen Det' sgu bare iorden makker =^ (thumbs-up i mangel af emoji) Skulle der være andre spørgsmål, så råber du bare højt, forummet her er fuldt af dygtige mennesker  No worries mate =^ (thumbs-up -- cuz we're lacking emoji) ...got questions -- just holler, this forum is full of people in the know  Regards Benny ---------------------------------------------------------------------- Alexx2000 · 2025-06-29 11:21 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 ComboBox.ItemIndex := ComboBox.Items.IndexOfObject(TObject(PtrInt(Que. FieldByName('koretoj').AsInteger))); ---------------------------------------------------------------------- jamie · 2025-06-29 13:00 Quote from: Alexx2000 on June 29, 2025, 01:21:34 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ComboBox.ItemIndex := ComboBox.Items.IndexOfObject(TObject(PtrInt(Que. FieldByName('koretoj').AsInteger)));  There you go, I am glad someone is awake around here, I was on my phone and not able to do much more help.