VBA如何提取STR_FIX_PSA_XXX_1_0中XXX的那一段字符串,注意XXX是动态的(其内部可能含有_),组成的连续字符串
StringFixed:STR_FIX_PSA_RAD002_01_2_0
ScreenID:RAD002-01
可以看出StringFixed是包含ScreenID的,即RAD002-01 -> RAD002_01 -> 包含于STR_FIX_PSA_RAD002_01_2_0
其实我最希望的是有一种方法,可以按照我上面的流程得出结果比较:先将ScreenID里面的“-”转成"_",然后看转换后的ScreenID是否包含在StringFixed里面。有没有什么方法?
本人QQ:724835496,可以线上聊
我刚接触VBA,所以对其函数不是太熟悉
vba excel
[解决办法]
Dim p As Integer
Dim StringFixed As String, ScreenID As String
ScreenID = "RAD002-01"
StringFixed = "STR_FIX_PSA_RAD002_01_2_0"
p = InStr(StringFixed, Replace(ScreenID, "-", "_"))
If p Then
MsgBox "Included in StringFixed from byte " & p
Else
MsgBox "Not included"
End If