【问题标题】:InStr VBA differentiate between lower and upper characterInStr VBA区分上下字符
【发布时间】:2020-04-27 11:17:42
【问题描述】:

我正在使用下面的 vba 代码来检查密码是否有大写字母

'See if there is an upper case
    For i = 65 To 90
        If (InStr(1, Me.Password, Chr(i))) Then
            hasUpper = True
            Exit For
        End If
    Next i

但看起来像“asd12”这样的密码将Upper设置为true,因为Aa相同

有没有办法使用 Instr 函数来区分大小写?

【问题讨论】:

    标签: vba ms-access


    【解决方案1】:

    如果这只是大写字符,并且您不想使用正则表达式,那么一种简单的方法(这在性能方面有些欠佳,但密码检查需要额外的毫秒时间可能不会伤害任何人) 正在检查小写字符串是否等于字符串(在这种情况下不会有大写字符)。

    'See if there is an upper case
    If StrComp(Me.Password, LCase(Me.Password), vbBinaryCompare) <> 0 Then hasUpper = True
    

    【讨论】:

      猜你喜欢
      • 2018-04-11
      • 2014-03-31
      • 2014-06-25
      • 2023-02-25
      • 1970-01-01
      • 2016-09-11
      • 2017-04-30
      • 1970-01-01
      • 2012-08-20
      相关资源
      最近更新 更多