R
RichardJ
I am running into a problem with the InStr function on an Excel 95 xls
on some machines, usually the new builds with W2K and XP. When I use
the compare option TEXT , I get the runtime error '7' Out of Memory.
However, when I change the compare option BINARY, then it works.
Sub Test
' Compare option Text
ActiveSheet.Cells(4, 4).Value = InStr(1, "ABC", "B", 1) ' Error
' Compare option Binary
ActiveSheet.Cells(4, 4).Value = InStr(1, "ABC", "B", 0) ' Works
End Sub
Does this have anything to do with doublebyte character sets (DCBS) or
is it the OS builds (dlls) ? I have listed below the HELP file
content for InStr for reference.
Please help.
Thanks.
***********************************************************
INSTR Function (From Help)
***********************************************************
Returns the position of the first occurrence of one string within
another.
Syntax
InStr([start,]string1,string2[,compare])
Elements
The InStr function syntax has these parts:
Part Description
start Numeric expression that sets the starting position for each
search. If omitted, search begins at the first character position.
If start contains no valid data, an error occurs. Start is required
if compare is specified.
string1 String expression being searched. If string1 contains no
valid data, Null is returned.
string2 String expression sought. If string2 contains no valid data,
Null is returned.
compare Number specifying the type of string comparison. Specify 1 to
perform a textual case-insensitive comparison. Specify 0 (default) to
perform a binary comparison. If compare is Null
, an error occurs. Start is required if compare is specified. If
compare is omitted, the setting of Option Compare is used to determine
the type of comparison.
Return Values
Value Description
0 string1 is zero-length.
start string2 is zero-length.
0 string2 not found.
Position at which match is found string2 is found within string1.
0 start > string2.
Remarks
Note When Option Compare Text is specified, comparisons are textual
and case-insensitive. When Option Compare Binary is specified,
comparisons are strictly binary.
Note Another function (InStrB) is provided for use with the
double-byte character sets (DBCS) used in some Asian locales. Instead
of returning the character position of the first occurence of one
string within another, InStrB returns the byte position. In areas
where DBCS is not used, InStrB behaves the same as InStr.
on some machines, usually the new builds with W2K and XP. When I use
the compare option TEXT , I get the runtime error '7' Out of Memory.
However, when I change the compare option BINARY, then it works.
Sub Test
' Compare option Text
ActiveSheet.Cells(4, 4).Value = InStr(1, "ABC", "B", 1) ' Error
' Compare option Binary
ActiveSheet.Cells(4, 4).Value = InStr(1, "ABC", "B", 0) ' Works
End Sub
Does this have anything to do with doublebyte character sets (DCBS) or
is it the OS builds (dlls) ? I have listed below the HELP file
content for InStr for reference.
Please help.
Thanks.
***********************************************************
INSTR Function (From Help)
***********************************************************
Returns the position of the first occurrence of one string within
another.
Syntax
InStr([start,]string1,string2[,compare])
Elements
The InStr function syntax has these parts:
Part Description
start Numeric expression that sets the starting position for each
search. If omitted, search begins at the first character position.
If start contains no valid data, an error occurs. Start is required
if compare is specified.
string1 String expression being searched. If string1 contains no
valid data, Null is returned.
string2 String expression sought. If string2 contains no valid data,
Null is returned.
compare Number specifying the type of string comparison. Specify 1 to
perform a textual case-insensitive comparison. Specify 0 (default) to
perform a binary comparison. If compare is Null
, an error occurs. Start is required if compare is specified. If
compare is omitted, the setting of Option Compare is used to determine
the type of comparison.
Return Values
Value Description
0 string1 is zero-length.
start string2 is zero-length.
0 string2 not found.
Position at which match is found string2 is found within string1.
0 start > string2.
Remarks
Note When Option Compare Text is specified, comparisons are textual
and case-insensitive. When Option Compare Binary is specified,
comparisons are strictly binary.
Note Another function (InStrB) is provided for use with the
double-byte character sets (DBCS) used in some Asian locales. Instead
of returning the character position of the first occurence of one
string within another, InStrB returns the byte position. In areas
where DBCS is not used, InStrB behaves the same as InStr.