InStr([start, ]str1, str2[, compare])

[用途]:返回str2在str1中的位置。匹配成功时,返回值最小值为1,未匹配到时返回0。

[参数说明]:

  start:在str1中开始匹配的位置,1表示从头开始,不能为0或更小值。 可选,默认为1。

  str1:长字符串

  str2:匹配关键字

  compare:匹配方式,取值为0或1。0表示执行二进制匹配。1表示执行文本匹配,即,忽略大小写。可选,默认为0。如果已指定"compare",则必须要有”start“参数。

[Sample]

  Msgbox Instr("HelloWorld","Hello") ->返回1

  Msgbox Instr("HelloWorld","world") ->返回0,这说明"compare"默认为0。

  Msgbox Instr(1, "HelloWorld","world", 1) ->返回6 ,这说明"compare"为1时可忽略大小写。

  Msgbox Instr("HelloWorld","world", 1) ->出错,这说明如果已指定"compare",则必须要有”start“参数。

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-08-22
  • 2022-01-19
猜你喜欢
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-06-26
相关资源
相似解决方案