Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strComp not working

Status
Not open for further replies.

sshafe

Programmer
Oct 18, 2002
71
US
I'm about to pull my hair out with this problem. I am trying to compare directories to make sure the are the same using the strComp.

If (strComp(strTogether, dbfile1, vbTextCompare) = 0) then

result:

no match on C:\DB2\NODE0000\SQL00010 C:\DB2\NODE0000\SQL00010

Ideas????

Thanks in advance.
 
Maybe there is white space before or after the one of the values. Try this:

Code:
If (strComp(Trim(strTogether), Trim(dbfile1), vbTextCompare) = 0)  then
 
I trim the variables right before this step:

strTogether = trim(strTogether)
dbfile1 = trim(dbfile1)
 
Is there any reason why you are using the string compare method as opposed to just simply testing for equality? Are there any times where you are looking for a substring within a larger string? You may just want to test if they are simply equal to each other. String compare should have worked however. It might be interpreting those slashes in your strings as escape sequences, but not sure. If that is the case, you could use the Replace() function to switch the "\" characters with another token character. Sorry I couldn't help anymore...
 
I've tried just about everything from putting an extra \ so that it would take the next as a literal to doing =. I've also tried setting them as regular expressions to try and match that way.

I'm just don't know what else to try. :-(
 
they cant be the same
is there a zero rather than an O letter
run through the whole string comparing each character until you find the one that doesnt match
change them to lower case and pipe them to the screen, this should show up the o or number thing
 
Have you tried to hard code the strComp function just to test. Try this:
WScript.Echo StrComp("C:\DB2\NODE0000\SQL00010","C:\DB2\NODE0000\SQL00010")

and see if this gives you 0 if it does then there is something with the variables. I ran this and it gave me 0. I copied the two strings from your post.
 
I pulled the strings from the log file I'm writing to and did a compare with those, they did match. So if that's the case and they are indeed the same, why aren't the variables matching within the script?
 
OK, just for other's who might have the same problem as I did, here was the problem....HIDDEN CARRIAGE RETURN...

I simply removed it from the string and now it works like a charm :)

Thanks for everyone's help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top