use*_*809 1 excel vba excel-vba
我需要在If语句中比较2变量,但我仍然希望它重新生成如果除了案例之外的所有内容都是相同的.我知道不能写这个,但这里是我想要做的事情:
If (str1=str2 matchcase:=false) then
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?谢谢
虽然我更喜欢@mr.Reband 答案,但您仍然可以参考这个使用StrComp函数的替代方案。
Sub test()
Dim str1 As String
Dim str2 As String
str1 = "test"
str2 = "Test"
MsgBox StrComp(str1, str2, vbTextCompare)
'Return Values
'
'The StrComp function has the following return values:
'
'If StrComp returns
'string1 is less than string2 -1
'string1 is equal to string2 0
'string1 is greater than string2 1
'string1 or string2 is Null Null
End Sub
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7895 次 |
| 最近记录: |