且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VBA,如果字符串包含某个字母

更新时间:2023-02-26 12:09:26

尝试使用InStr函数,该函数返回找到字符的字符串中的索引.如果InStr返回0,则找不到该字符串.

Try using the InStr function which returns the index in the string at which the character was found. If InStr returns 0, the string was not found.

If InStr(myString, "A") > 0 Then

InStr MSDN网站

对于分配给newStr的行上的错误,也将oldStr.IndexOf转换为该InStr函数.

For the error on the line assigning to newStr, convert oldStr.IndexOf to that InStr function also.

Left(oldStr, InStr(oldStr, "A"))