1

为什么Like功能不起作用?在这种情况下,它返回:

“不,这不对”

Sub test()
    If "*ыписка по договору ук-004#1500333*" Like "выписка по договору ук-004#1500333 стд.xlsx" Then
        MsgBox "Yes, it is!"
    Else
        MsgBox "No, it's not"
    End If    
End Sub
4

2 回答 2

8

你有向后的字符串。

If {string} Like {substring w/wildcards} Then

Sub test()
    If "выписка по договору ук-004#1500333 стд.xlsx" Like "*ыписка по договору ук-004#1500333*" Then
        MsgBox "Yes, it is!"
    Else
        MsgBox "No, it's not"
    End If
End Sub
于 2018-10-26T14:52:36.773 回答
2

You can also use InStr instead if your goal is to verify the existence of a string in another:

Sub test()   
    If  InStr("выписка по договору ук-004#1500333 стд.xlsx", _
        "ыписка по договору ук-004#1500333") > 0 Then
        MsgBox "Yes, it is!"
    Else
        MsgBox "No, it's not"
    End If    
End Sub
于 2018-10-26T14:55:20.337 回答