2017-04-27 52 views

回答

1

你可以用通配符*一起使用Like操作:当且仅当MyString包含"anytext"

MyString Like "*anytext*" 

将返回true。详情请参阅this

0

使用Instr功能

Dim pos As Integer 

pos = InStr("find the comma, in the string", ",") 

将在POS返回15

如果没有找到则返回0

如果你需要找到一个Excel公式可以用逗号=FIND(",";A1)功能。

请注意,如果要使用Instr来查找字符串的位置不区分大小写,请使用Instr的第三个参数并将其设置为const vbTextCompare(对于死硬件只能使用1)。如果比较指定所需的启动参数:

Dim posOf_A As Integer 

posOf_A = InStr(1, "find the comma, in the string", "A", vbTextCompare) 

会给你14

注意一个值,你必须为我联系的规范规定,指定在这种情况下开始位置。

抢答:Check if a string contains another string