|
-
Mar 2nd, 2004, 04:09 AM
#1
Thread Starter
Lively Member
Looking for character in a STRING
Hi
How can I search for a character (i.e. '&' or '+' or '%' or ',') in a string?
Thanks in advance
My software doesn't have bugs, It has undocumented features!
-
Mar 2nd, 2004, 04:12 AM
#2
Use the instr function
[copy-past from MSDN]
Returns a Variant (Long) specifying the position of the first occurrence of one string within another.
Syntax
InStr([start, ]string1, string2[, compare])
The InStr function syntax has thesearguments:
Part Description
start Optional.Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start containsNull, an error occurs. The start argument is required if compare is specified.
string1 Required.String expression being searched.
string2 Required. String expression sought.
compare Optional. Specifies the type ofstring comparison. If compare is Null, an error occurs. If compare is omitted, the Option Compare setting determines the type of comparison.
Settings
The compare argument settings are:
Constant Value Description
vbUseCompareOption -1 Performs a comparison using the setting of the Option Compare statement.
vbBinaryCompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a textual comparison.
vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database.
Return Values
If InStr returns
string1 is zero-length 0
string1 is Null Null
string2 is zero-length start
string2 is Null Null
string2 is not found 0
string2 is found within string1 Position at which match is found
start > string2 0
-
Mar 2nd, 2004, 04:20 AM
#3
Thread Starter
Lively Member
Thanks - I'm gonna try the code now.
My software doesn't have bugs, It has undocumented features!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|