Cell value in ListBox

I getting strange result from a desktop app from a cell in a listbox. Code below:

[code] dim s as string
s = lbImage.cell(lbImage.listIndex,0)
if lbImage.listindex = -1 then
Msgbox “Please select a Row in the List Box and try again.”
return
end if
// make sure user wants to delete this record
dim n as integer
n=MsgBox(“Do you want to delete selected image?” + EndOfLine + “Can not undo.”,52)
if n=6 then

s = lbImage.cell(lbImage.listIndex,0)[/code]

The first(2) and last line of code were add to display for debugging. The second line has s = 26 (which is correct), and the last line has s = 24. There is NO code between the first(2) and last that should effect the cell. There is one unusual thing about this listbox, I have a very large string stored in the celltag 0 (1.2MB)

Maybe a bug as a result of the large string in the celltag? Any thoughts?

are you sure it isn’t because your listbox is losing focus when the Msgbox appears?

perhaps it would be best to store the listindex at the top of the procedure instead of going back to the listbox everytime

Dave: Would that make a difference? I should have mention the code above is in a Button.action event NOT an event of the listbox.

BTW, Dave in this app I’m adding some code about Picture to String and String to Picture you posted. Thanks.

dim s as string
dim indx as integer=lbImage.Listindex
  s = lbImage.cell(indx,0)
  if indx = -1 then
    Msgbox "Please select a Row in the List Box and try again."
    return
  end if
  // make sure user wants to delete this record
  dim n as integer
  n=MsgBox("Do you want to delete selected image?" + EndOfLine + "Can not undo.",52)
  if n=6 then
    
    s = lbImage.cell(Indx,0)

This way regardless of what other events occur (gotfocus/lostfocus etc), INDX stays consistent

And storing 1.2Mg in a celltag is a bit excessive… where is it coming from? If a database, store the key to the data, not the data itself

Thanks Dave.

In this app it currently store thumbnail of image the user want to save a reference, like an image on an invoice for work on an RV. Most picture this is not a problem, as the image is good enough, but for not for printed/written paper work. So what I’m doing is not messing with the thumbnails and adding the capabilities to save image in original size. I could save as a separate file and store an key to point to the file in folder with the database. Would this be better than putting image in the DB?

Mots probably not. A string is a pointer, so only the address of the string location in the heap is stored within the CellTag.

Same case, a picture is a pointer to data in the heap. So if it the memory used for all images is not excessive for the application, then it won’t be for the listbox.