|
-
Dec 25th, 2009, 10:50 PM
#4
Re: Process1.MainModule.FileName has repeated path.
First up, get rid of this line:
Code:
Dim Process As New Process()
That is not doing anything useful and it's actually creating a Process object that you never use, so it's inefficient.
Secondly, it's really a bad idea to use a type name as the name of a variable of that type. It simply make your code confusing. Also, you should be consistent and name ALL your variables starting with a lower-case letter. As such, your 'Process' variable should become 'proc' or 'currentProcess' or something like that.
Thirdly, you really should get rid of that "On Error Resume Next" and NEVER, EVER use it again. If there's an error, why would you want to simply ignore it and continue? If there's an error, don't you want to know what it is so that you can fix it? If there are legitimate reasons that an exception may be thrown in your code then you should use structured exception handling, i.e. a Try...Catch block, and examine the exception to see what you need to do to fix it.
Finally, I can't see what that If block is achieving anyway. You say that if the file name is an empty string then add an empty string and if it's not then add the file name. If the file name is an empty string and you add the file name, aren't you adding an empty string anyway? If so, what's the If block for?
I suggest that you address all those points and then post back if you still have an issue.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|