首页 > 解决方案 > 检查变量中是否存在特定值

问题描述

在我的代码中,我需要检测变量中是否存在事件。我尝试在 if 语句中实现它,但它不起作用。任何想法谢谢,下面是我的代码:我的变量名称是:Planning_CAMBON19_VM_Evenements_T3_2020.xlsx

 Dim strPath As String


strPath = nomfichier_Boutique
'MsgBox (strPath)
Debug.Print strPath

Dim strFilee As String
strFilee = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))

MsgBox (strFilee)

If strFilee = "Evenements" Then

MsgBox "vALID"

Else

MsgBox "iNVALID"
End If

标签: vba

解决方案


InStr是您要检查一个字符串是否存在于另一个字符串中的内容。

If InStr(strFilee, "Evenements") Then

推荐阅读