String Comparisons 
Author Message
 String Comparisons

How would I go about comparing two strings?
Example: I have an array filled with string values and I'd like to do some
comparisons. I tried this but it did not work:

if CStr(arrayHold(1)) > CStr(arrayHold(2)) then
    Response.Write "arrayHold(1) is greater"
end if

Any tips?

Thanks in advance!



Sun, 11 May 2003 03:00:00 GMT  
 String Comparisons


Fri, 19 Jun 1992 00:00:00 GMT  
 String Comparisons
I was trying to compare the file names so I could sort descending (Z-A) . I
got it to work though by converting values with UCase. Thanks anyway


Quote:
> Hi

> what do you want to compare ?

> the length of the strings ?
> if so, maybe use len(Cstr(arrHold(1))) > len(......

> --
> Tom
> -------------------------------------
> http://engines2go.com - Fast access to all the major search engines.
> No Ads, Pictures or Banners.



> > How would I go about comparing two strings?
> > Example: I have an array filled with string values and I'd like to do
some
> > comparisons. I tried this but it did not work:

> > if CStr(arrayHold(1)) > CStr(arrayHold(2)) then
> >     Response.Write "arrayHold(1) is greater"
> > end if

> > Any tips?

> > Thanks in advance!



Sun, 11 May 2003 03:00:00 GMT  
 String Comparisons


Fri, 19 Jun 1992 00:00:00 GMT  
 String Comparisons
Hi

what do you want to compare ?

the length of the strings ?
if so, maybe use len(Cstr(arrHold(1))) > len(......

--
Tom
-------------------------------------
http://engines2go.com - Fast access to all the major search engines.
No Ads, Pictures or Banners.


Quote:
> How would I go about comparing two strings?
> Example: I have an array filled with string values and I'd like to do some
> comparisons. I tried this but it did not work:

> if CStr(arrayHold(1)) > CStr(arrayHold(2)) then
>     Response.Write "arrayHold(1) is greater"
> end if

> Any tips?

> Thanks in advance!



Mon, 12 May 2003 02:36:13 GMT  
 String Comparisons
Two ways to do case insensitive string comparisons:

1) normalize the case of the 2 strings:

if LCase(arrayHold(1)) > LCase(arrayHold(2)) then
    Response.Write "arrayHold(1) is greater"
end if

or

if UCase(arrayHold(1)) > UCase(arrayHold(2)) then
    Response.Write "arrayHold(1) is greater"
end if

2) use the StrComp function:

if StrComp(arrayHold(1),arrayHold(2),vbTextCompare) = 1 then
    Response.Write "arrayHold(1) is greater"
end if

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup...
--

Quote:

> How would I go about comparing two strings?
> Example: I have an array filled with string values and I'd like to do some
> comparisons. I tried this but it did not work:

> if CStr(arrayHold(1)) > CStr(arrayHold(2)) then
>     Response.Write "arrayHold(1) is greater"
> end if

> Any tips?

> Thanks in advance!



Mon, 12 May 2003 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. String comparison does not work

2. Single quote and dash act strangely in string comparison

3. string comparison statement

4. Looking for 'fuzzy' string comparison routine

5. SQL string comparison - dbgrid

6. I need a FAST string comparison in VB

7. Using a wildcard string comparison in a select case statement

8. String comparison

9. String comparisons/similarities

10. String comparison

11. : Need Help with Now() and String comparison

 

 
Powered by phpBB® Forum Software