PDA

View Full Version : String manipluation in listbox?



rado
03-17-2006, 09:12 AM
I have few items in my listbox like:
monday1.something.txt
saturday2.something.txt
sunday4.something.txt
......

My question for all good people here is:
How can I get new string from each item in the listbox that contain characters until "."(dot). for example, I need this:
newstring1 = monday1,
newstring2 = saturday2,
newstring = sunday4 ...

and so on.

Thanks, Rado

TJS
03-17-2006, 10:32 AM
Give this a shot....


-- get the total number of items in you listbox
nCountdown = ListBox.GetCount("YourListBoxName");

-- start at the last item and loop your way up changing the text as we go
while nCountdown > 0 do

-- get the current text for this item
strItemText = ListBox.GetItemText("YourListBoxName", nCountdown);

-- cut the junk from the end of the string
strItemText = String.TrimRight(strItemText, ".something.txt");

-- set the item to the new text
ListBox.SetItemText("YourListBoxName", nCountdown, strItemText);

-- set the counter to the next item
nCountdown = nCountdown -1

end

rado
03-17-2006, 10:36 AM
Thank you very much. Let me try.

rado
03-17-2006, 11:20 AM
It works. Thank you so much.
Rado