Excel VBA在对比字符串的时候不区分大小写的语句(实测可用)

网站编辑
1353
文章
2
评论
2012/02/0710:21:50
评论
21,504 views

代码如下
Option Compare Text '以文本方式比较,不区分大小写(此语句必须写在所有过程之前,不可以在Sub中定义,否则报错)
Sub Test()
Dim T1 As String, T2 As String, T3 As String
T1 = "Yuanzifan.com"
T2 = "YuanZIFAN.COm"
T3 = "YuAnZiFaN.CoM"
If T1 Like T2 = True Then MsgBox "True" '使用like而不是“=”
If T2 Like T3 = True Then MsgBox "True"
If T2 Like T3 = True Then MsgBox "True"
End Sub

匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: