Prev: How to save a picturebox's image to a .PNG file? (VB6)
Next: vb6 xpsp3 DEP stops P&D generated setup.exe
From: Mike S on 8 Aug 2010 03:26 On 8/7/2010 7:47 PM, David wrote: > Mr. Provance: > > That's "Not" where the problem is coming from. > After a lot work, it appears Command is returning a string with > quotes delimited around it while a normal VB string is shown without. > Displayed both to labels and that is the difference showing. > > However, after removing both quotes (beginning and ending) > rather than Err 52 (Bad File Name). The program locks big time. > > So OBVIOUSLY I'm doing something wrong by getting the file name > in VB using Command from Explorer and then trying to search > and replace within that file name from VB using a Right Context Menu. > > Any ideas??. Please show the string Command is receiving, the string you're working with, and the code that uses the string.
From: Larry Serflaten on 8 Aug 2010 03:28 "David" <NoWhere(a)earthlink.net> wrote > > That's "Not" where the problem is coming from. > After a lot work, it appears Command is returning a string with > quotes delimited around it while a normal VB string is shown without. > Displayed both to labels and that is the difference showing. > > However, after removing both quotes (beginning and ending) > rather than Err 52 (Bad File Name). The program locks big time. > > So OBVIOUSLY I'm doing something wrong by getting the file name > in VB using Command from Explorer and then trying to search > and replace within that file name from VB using a Right Context Menu. > > Any ideas??. Don't be so sure what is and isn't obvious, you might find a simple typo wreaks havok in your code. For example, is Option Explicit the first line in all your code modules? If not, make it so and try again. If your program works when you hard code a string, but not when you use the Command function, then something is wrong with your handling of the Command function. Are you sure you are getting only one file name? Have you double checked your ability to remove the quotes on either end? Do you test to be sure what you end up with is a valid file name? etc.. etc.... Programs don't fall into place, you have to put every letter exactly in place for the thing to run. Likewise you should check your data to be sure it is exactly what you expect all through the process. LFS
From: David on 8 Aug 2010 12:58 Thanks all for the help. First let me thank everyone for their assistance. Greatly appreciated. For what I thought would take me an hour to write a simple program to substitute the current folder on my system for the embedded folder associated with a image on a downloaded web page has turned into a good reminder of "Murray's Law". That said, it appears I may be dealing with two issues. 1) Getting a file string from Explorer from VB using the Command line function where the file name contains spaces. In this instance stripping the quotes from the beginning and end of the file name that is returned on the command line "appears" (juries still out) to resolve the issue. This was determined by hard coding the directory then sending it to a label as well as sending the string returned from command to another label. Further internet research seems to confirm this fact. [CODE] strExplorerPath = Command$() 'The Command Line returns a string with quotes on 'beginning and end. These need to be removed otherwise 'fails as string 'Strip right quote character If Right$(strExplorerPath, 1) = Chr$(34) Then strExplorerPath = Left$(strExplorerPath, Len(strExplorerPath) - 1) End If 'Strip left quote character If Left$(strExplorerPath, 1) = Chr$(34) Then strExplorerPath = Right$(strExplorerPath, Len(strExplorerPath) - 1) End If [/CODE] 2) The second issue: I just happened to download a second web page to use for testing that contains some type of scheme to keep a search/replace program from altering the htm file (my luck). So I need to spend some time figuring out what was done and how to beat it as I'm sure it may be used more than just the web page I picked. Consequently, I am closing this thread. "Larry Serflaten" <serflaten(a)gmail.com> wrote in message news:i3lma4$g9e$1(a)news.eternal-september.org... > > "David" <NoWhere(a)earthlink.net> wrote >> >> That's "Not" where the problem is coming from. >> After a lot work, it appears Command is returning a string with >> quotes delimited around it while a normal VB string is shown without. >> Displayed both to labels and that is the difference showing. >> >> However, after removing both quotes (beginning and ending) >> rather than Err 52 (Bad File Name). The program locks big time. >> >> So OBVIOUSLY I'm doing something wrong by getting the file name >> in VB using Command from Explorer and then trying to search >> and replace within that file name from VB using a Right Context Menu. >> >> Any ideas??. > > Don't be so sure what is and isn't obvious, you might find a simple > typo wreaks havok in your code. For example, is Option Explicit the > first line in all your code modules? If not, make it so and try again. > > If your program works when you hard code a string, but not when > you use the Command function, then something is wrong with your > handling of the Command function. Are you sure you are getting only > one file name? Have you double checked your ability to remove the > quotes on either end? Do you test to be sure what you end up with is > a valid file name? etc.. etc.... > > Programs don't fall into place, you have to put every letter exactly in > place for the thing to run. Likewise you should check your data to > be sure it is exactly what you expect all through the process. > > LFS > >
First
|
Prev
|
Pages: 1 2 3 Prev: How to save a picturebox's image to a .PNG file? (VB6) Next: vb6 xpsp3 DEP stops P&D generated setup.exe |