小编use*_*212的帖子

比较VBA中的字符串

我有一个基本的编程背景,已经多年自给自足但这个问题我似乎无法解决.我在VBA中有一个程序,我需要比较两个字符串.我已经尝试使用以下方法来比较我的字符串,但无济于事:

//Assume Cells(1, 1).Value = "Cat"

Dim A As String, B As String

A="Cat"

B=Cell(1, 1).Value

If A=B Then...

If A Like B Then...

If StrCmp(A=B, 1)=0 Then...

I've even tried inputting the Strings straight into the code to see if it would work:

If "Cat" = "Cat" Then...

If "Cat" Like "Cat" Then...

If StrCmp("Cat" = "Cat", 1) Then...
Run Code Online (Sandbox Code Playgroud)

VBA由于某种原因不能将这些字符串识别为等号.通过Debugger时,它显示StrComp返回1.我的字符串是否有不同的Char长度?谢谢你的帮助.

string vba compare

4
推荐指数
1
解决办法
9万
查看次数

标签 统计

compare ×1

string ×1

vba ×1