String = String comparison style (theory?)

2019-07-17 00:54发布

I can't test the code out at the moment (no laptop), but in a If statement as below:

Dim StrA As String, StrB As String

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

Does the Ifstatement check the strings in a binary or textual manner?

2条回答
何必那么认真
2楼-- · 2019-07-17 01:25

depends on settings option compare text is most common, I think

查看更多
啃猪蹄的小仙女
3楼-- · 2019-07-17 01:34

The comparison is usually textual, stra=STRA, but you can use 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
查看更多
登录 后发表回答