Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

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
0
danorme
Asked:
danorme
  • 3
1 Solution
 
sakuya_suCommented:
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)
0
 
cetafuddCommented:
--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
0
 
sakuya_suCommented:
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
0
 
danormeAuthor Commented:
I will issue points once I get this little thing to work.  Any code examples would be appreciated.
0
 
sakuya_suCommented:
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
"\\servername\main_folder\K9999-SMITH\filename.doc"

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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now