Rename Folder and Listbox Value

This is an odd one, but I will do my best to ask the question correctly.
I have a program that is workflow related.  The first part of the process creates a folder with the session number(lets say 600) and the customers last name(lets say smith), so the path created looks like this; \\servername\main_folder\600smith\*.  Now everytime my employees upload a document, based on which session they are in it will put that document in the above folder.

Here comes the tricky part for me.

At stage 3 of the workflow a loan number is associated to this session so at this point I have to rename the folder to the loan number(lets say K9999) and the persons last name.  Now when this is done I also have to rename the listbox items to correspond with the new path.

So instead of  \\servername\main_folder\600smith\filename.doc it will become \\servername\main_folder\K9999-SMITH\filename.doc and this will be in both the listbox of my program and on the shared network directory.

Thanks in advance
Who is Participating?
ok, for example:

say you have the 2nd item in the list as
" \\servername\main_folder\600smith\filename.doc"

and you want to change it to

you do this:

dim text as string

list1.listindex = 1 'This is to select that item
text = list1.text 'Text will contain the sting  \\servername\main_folder\600smith\filename.doc
DO YOUR PROCESSING HERE, so after the processing, text should=  "\\servername\main_folder\K9999-SMITH\filename.doc"

then, to update the list
list1.removeitem 1
list1.additem text, 1

of course, in your actual code you want to swap the number 1 with a variable so you can change which one to update and such
to update a listbox, you first have to have the listindex of the item you wish to update, then, you do:

.removeitem (INDEXNumber) 'oh btw i cant remember it completely, is it removeitem? its along the lines of remove, delete or something

then, do a additem(NEW PATH, INDEXnumber)
--find the item you want to replace and delete it  
For I = 0 To YourListBox.ListCount - 1
      IF ThisOneIsTheOneYouWantToReplace
           YourListBox.RemoveItem I  
      end if
Next I

--add new item with the updated path
YourListBox.AddItem item, index

hope it helps
a modification on Ceta' code:

--add new item with the updated path
YourListBox.AddItem item, index

instead of that, do:
--add new item with the updated path
YourListBox.AddItem item, I '<-- here since from before, you are deleteing the item at I, you should insert the new one back at that place
danormeAuthor Commented:
I will issue points once I get this little thing to work.  Any code examples would be appreciated.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.