It's because of how you exit your smaller While loop. Your logic is
set up so that if the user double-clicks on the listbox OR clicks on
"Save" OR clicks on "Cancel" OR there is an error, the program exits
the loop. The next piece of the program to run is dependent on the
output of the Dbl-Click property - even if that isn't what the user
clicked on! So in those cases you get a value of 0 from Dbl-Click and
the program falls apart when it uses this 0 in the part that builds
pathnames and you end up with a bad path that it then tries to tack
the value of the "Save As" control onto.

I think your program would benefit from a bit more thought about its
structure. If it was based around an Event structure or a State
Machine, you would be able to know exactly what the user had clicked
on, rather than that they'd just clicked on *something* and be really
specific about what code gets run in each case.

Hope this helps,
James.

Reply via email to