有兴趣开发跨
多个平台
扩展 Office 体验的解决方案吗? 查看新的
Office 外接程序模型
。 与VSTO外接程序和解决方案相比,Office外接程序占用的空间较小,您可以使用几乎任何Web编程技术(例如HTML5,JavaScript,CSS3和XML)来构建它们。
InStr
([
start
],
string1
,
string2
, [
compare
])
InStr
函数语法有以下
参数
:
start
可选。 设置每次搜索的起始位置的
数字表达式
。 如果忽略,则搜索从第一个字符位置开始。 如果
start
包含
Null
,则出现错误。 如果指定了
compare
,则
start
参数是必需的。
string1
必需。 要搜索的
字符串表达式
。
string2
必需。 搜索到的字符串表达式。
compare
可选。 指定
字符串比较
的类型。 如果
compare
为
Null
,则会发生错误。 如果省略
compare
,则
Option Compare
设置将决定比较的类型。 指定有效的 LCID (LocaleID) 以在比较中使用区域设置特定规则。
compare
参数设置如下。
InStrB
函数适用于包含在字符串中的字节数据。
InStrB
返回某字符串在其他字符串中首次出现的字节位置,而不返回其字符位置。
本示例使用
InStr
函数来返回某字符串在其他字符串中首次出现的位置。
Dim SearchString, SearchChar, MyPos
SearchString ="XXpXXpXXPXXP" ' String to search in.
SearchChar = "P" ' Search for "P".
' A textual comparison starting at position 4. Returns 6.
MyPos = Instr(4, SearchString, SearchChar, 1)
' A binary comparison starting at position 1. Returns 9.
MyPos = Instr(1, SearchString, SearchChar, 0)
' Comparison is binary by default (last argument is omitted).
MyPos = Instr(SearchString, SearchChar) ' Returns 9.
MyPos = Instr(1, SearchString, "W") ' Returns 0.
函数 (Visual Basic for Applications)
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。