Connecting Tech Pros Worldwide Forums | Help | Site Map

String Compare first 6 characters

gerards_@hotmail.com
Guest
 
Posts: n/a
#1: Nov 21 '05
Hi all,

What I am trying to do is to String Compare just the first 6 characters
of a string.

For example:

For the compare string "Powama" I want to return true for any strings
that contains these first 6 characters (in order).

So for the following strings the result should be:

Powamaster.exe ---> True
Powama~2.exe -----> True
Powama~11.exe-----> True
notepad.exe ------> False

etc...

It would also be great if it wasn't case sensitive.

I am using this code right now but it compares the whole word:

StrComp(CompareLogProcess, CompareTskProcess, 1) = 0

Any help greatly appreciated (please email me directly or post)
Thanks

Powerguy


Stephany Young
Guest
 
Posts: n/a
#2: Nov 21 '05

re: String Compare first 6 characters


How about:

<boolean> = <string1>.ToLower().StartsWith(<string2>.ToLower() )

<gerards_@hotmail.com> wrote in message
news:1102647401.284247.223260@f14g2000cwb.googlegr oups.com...[color=blue]
> Hi all,
>
> What I am trying to do is to String Compare just the first 6 characters
> of a string.
>
> For example:
>
> For the compare string "Powama" I want to return true for any strings
> that contains these first 6 characters (in order).
>
> So for the following strings the result should be:
>
> Powamaster.exe ---> True
> Powama~2.exe -----> True
> Powama~11.exe-----> True
> notepad.exe ------> False
>
> etc...
>
> It would also be great if it wasn't case sensitive.
>
> I am using this code right now but it compares the whole word:
>
> StrComp(CompareLogProcess, CompareTskProcess, 1) = 0
>
> Any help greatly appreciated (please email me directly or post)
> Thanks
>
> Powerguy
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#3: Nov 21 '05

re: String Compare first 6 characters


Powerguy

Do you mean.
\\\
if mystring.substring(0,6) = "powama" then
///
I hope this helps

Cor

<gerards_@hotmail.com> schreef in bericht
news:1102647401.284247.223260@f14g2000cwb.googlegr oups.com...[color=blue]
> Hi all,
>
> What I am trying to do is to String Compare just the first 6 characters
> of a string.
>
> For example:
>
> For the compare string "Powama" I want to return true for any strings
> that contains these first 6 characters (in order).
>
> So for the following strings the result should be:
>
> Powamaster.exe ---> True
> Powama~2.exe -----> True
> Powama~11.exe-----> True
> notepad.exe ------> False
>
> etc...
>
> It would also be great if it wasn't case sensitive.
>
> I am using this code right now but it compares the whole word:
>
> StrComp(CompareLogProcess, CompareTskProcess, 1) = 0
>
> Any help greatly appreciated (please email me directly or post)
> Thanks
>
> Powerguy
>[/color]


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#4: Nov 21 '05

re: String Compare first 6 characters


<gerards_@hotmail.com> schrieb:[color=blue]
> What I am trying to do is to String Compare just the first 6 characters
> of a string.
>
> For example:
>
> For the compare string "Powama" I want to return true for any strings
> that contains these first 6 characters (in order).
>
> So for the following strings the result should be:
>
> Powamaster.exe ---> True
> Powama~2.exe -----> True
> Powama~11.exe-----> True
> notepad.exe ------> False
>
> etc...
>
> It would also be great if it wasn't case sensitive.[/color]


If 'Option Compare Text' is used (this is the default), comparing using the
'=' operator would not be case sensitive:

\\\
If Left(FileName, 6) = "Powama" Then
...
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Closed Thread