strings = get(hObject, 'string');
curval = get(hObject, 'value');
if iscell(strings)
curstring = strings{curval};
else
curstring = strings(curval, :);
end
Whether the string parameter is a cell array of strings, or a char array, depends on exactly how the listbox was initialized. If it was initialized to a single string that did not have any '|' characters, or initialized to a char array, then a char array will be the result, but if it was initialized to a cell array of strings, or to a single string that had on or more '|' characters, then a cell array will be the result.
Best Answer