Using StrComp

O

Otto Moehrbach

Excel XP & Win XP
I am losing hair over this. I want to compare 2 pieces of text that differ
in case only.
I place Option Compare Text at the top of the module and I don't. I've
tried both.
I finally tried the following code:
MsgBox StrComp("c.xls", "c.xls") with Option Compare Text at the top of the
module.
Given that they are the same and also given that a "True" in VBA is -1, I
expect a -1 in the MsgBox. I get a 0.
My question: How do I get a True when I compare C.xls with C.XLS and when I
compare c.xls with c.xls, both? Thanks for your time. Otto
 
G

Guest

Check out help on the strcomp function.
Try setting the compare argument to vbTextCompare.
Also check out the return values. I don't believe that your assumptions of
the -1 is correct.


Regards,

OssieMac
 
G

Guest

check out Help on the StrCompare function.
Try setting the compare argument to vbtextcompare.
Also check out the Retrun Values. I don't believe that your assumption re
the -1 is correct for StrCompare.

Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top