【问题标题】:String = String comparison style (theory?)String = 字符串比较风格(理论?)
【发布时间】:2020-07-13 22:07:14
【问题描述】:

我目前无法测试代码(没有笔记本电脑),但在If 语句中如下:

Dim StrA As String, StrB As String

IF StrA = StrB Then
   'code for true result
Else
   'code for false result
End If

Ifstatement 是否以二进制或文本方式检查字符串?

【问题讨论】:

  • 二进制或文本是什么意思?我倾向于说这个问题是无关紧要的。它检查字符串是否相等,这就是所有需要知道的。

标签: ms-access if-statement vba


【解决方案1】:

比较通常是文本,stra=STRA,但你可以使用 StrComp:

 StrComp("stra","STRA",vbbinarycompare)

http://office.microsoft.com/en-ie/access-help/strcomp-function-HA001228914.aspx

Sub IsIt()
'Option Compare Database (default): True
'Option Compare Text : True
'Option Compare Binary : False
If "stra" = "STRA" Then
    Debug.Print True
Else
    Debug.Print False
End If
End Sub

【讨论】:

  • 谢谢,这与 Beth 的回答有关,但也给了我一些东西来测试它!
【解决方案2】:

取决于settings option compare text 是最常见的,我认为

【讨论】:

    猜你喜欢
    • 2020-04-16
    • 1970-01-01
    • 2013-06-09
    • 2018-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-05
    相关资源
    最近更新 更多