Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default String Function 'Like' and Special Characters

I'm trying to find string values that start with a bracket ("[") character. However, I know the bracket character serves a special purpose in regular expressions and string functions.

For example, the first rKeyName.Value is "[paths]", but in the following code snippet; the IF statement produces an error and all combinations of apostrophes, quotes, and backslashes that I have tried don't match "[paths]".


VB:
------------------------------------------------------------------------------
For Each rKeyName In rKeySection
If rKeyName.Value Like "[*" Then
strKeySection = rKeyName.Value
Else
strKeyName = rKeyName.Value
strKeyValue = rKeyName.Offset(0, 1).Value
oConfigData.Add strKeySection, strKeyName, strKeyValue
End If
Next
------------------------------------------------------------------------------


Thanks in advance,

Carl
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default String Function 'Like' and Special Characters

Hi
try
If rKeyName.Value Like "~[*" Then

-----Original Message-----
I'm trying to find string values that start with a

bracket ("[") character. However, I know the bracket
character serves a special purpose in regular expressions
and string functions.

For example, the first rKeyName.Value is "[paths]", but

in the following code snippet; the IF statement produces
an error and all combinations of apostrophes, quotes, and
backslashes that I have tried don't match "[paths]".


VB:
----------------------------------------------------------

--------------------
For Each rKeyName In rKeySection
If rKeyName.Value Like "[*" Then
strKeySection = rKeyName.Value
Else
strKeyName = rKeyName.Value
strKeyValue = rKeyName.Offset(0, 1).Value
oConfigData.Add strKeySection, strKeyName,

strKeyValue
End If
Next
----------------------------------------------------------

--------------------


Thanks in advance,

Carl
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default String Function 'Like' and Special Characters

The '~' didn't work, but thanks for the help. I ended up using the Left(rKeyName.Value, 1) = "[" comparison. That worked, but I would still like to know how to get the Like function to work with special characters.

Thanks,

Carl

"Frank Kabel" wrote in message ...
Hi
try
If rKeyName.Value Like "~[*" Then

-----Original Message-----
I'm trying to find string values that start with a

bracket ("[") character. However, I know the bracket
character serves a special purpose in regular expressions
and string functions.

For example, the first rKeyName.Value is "[paths]", but

in the following code snippet; the IF statement produces
an error and all combinations of apostrophes, quotes, and
backslashes that I have tried don't match "[paths]".


VB:
----------------------------------------------------------

--------------------
For Each rKeyName In rKeySection
If rKeyName.Value Like "[*" Then
strKeySection = rKeyName.Value
Else
strKeyName = rKeyName.Value
strKeyValue = rKeyName.Offset(0, 1).Value
oConfigData.Add strKeySection, strKeyName,

strKeyValue
End If
Next
----------------------------------------------------------

--------------------


Thanks in advance,

Carl
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default String Function 'Like' and Special Characters

from VBA's (xl2002) help for Like:

Note To match the special characters left bracket ([), question mark (?),
number sign (#), and asterisk (*), enclose them in brackets. The right bracket
(]) can't be used within a group to match itself, but it can be used outside a
group as an individual character.

Vagabond Software wrote:

The '~' didn't work, but thanks for the help. I ended up using the Left(rKeyName.Value, 1) = "[" comparison. That worked, but I would still like to know how to get the Like function to work with special characters.

Thanks,

Carl

"Frank Kabel" wrote in message ...
Hi
try
If rKeyName.Value Like "~[*" Then

-----Original Message-----
I'm trying to find string values that start with a

bracket ("[") character. However, I know the bracket
character serves a special purpose in regular expressions
and string functions.

For example, the first rKeyName.Value is "[paths]", but

in the following code snippet; the IF statement produces
an error and all combinations of apostrophes, quotes, and
backslashes that I have tried don't match "[paths]".


VB:
----------------------------------------------------------

--------------------
For Each rKeyName In rKeySection
If rKeyName.Value Like "[*" Then
strKeySection = rKeyName.Value
Else
strKeyName = rKeyName.Value
strKeyValue = rKeyName.Offset(0, 1).Value
oConfigData.Add strKeySection, strKeyName,

strKeyValue
End If
Next
----------------------------------------------------------

--------------------


Thanks in advance,

Carl
.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Special Characters Using Function TGV Excel Discussion (Misc queries) 1 May 22nd 09 09:18 AM
Find Special Characters Using Function TGV Excel Discussion (Misc queries) 4 May 22nd 09 08:50 AM
Insert Leading Characters If String Is Only 7 Characters Paperback Writer Excel Discussion (Misc queries) 2 April 21st 09 09:07 PM
Name Ranges: Function to convert special characters underscores Calanbraun Excel Worksheet Functions 2 August 20th 06 07:05 AM
Escape for special characters in string Jag Man Excel Programming 2 January 2nd 04 03:56 AM


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"