Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下 VBA 功能
Function ..... .......... If (IsNumeric(x) And ((x = "*9999999*") = False)) Then ....... Else ........... End If End Function
我需要知道一个字符串是否包含子字符串“9999999”。我怎样才能做到这一点?
您可以使用Like运算符。
Like
Sub test() Dim str1 As String Dim str2 As String str1 = "dhfjd9999999dfda" str2 = "ddsss999dfdfsfd" MsgBox str1 Like "*9999999*" MsgBox str2 Like "*9999999*" End Sub
If Instr(x, "9999999") > 0 Then ...应该这样做。
If Instr(x, "9999999") > 0 Then ...