在VBA for Excel中比较字符串时出现问题

时间:2019-06-03 10:52:25

标签: excel vba

我正在尝试制作一个Excel宏来将xls解析为xml,在我的代码的某些部分中,我需要比较字符串,但我不知道为什么它不起作用。这是代码:

Set newAtributte = oXMLFile.createAttribute("display")
            newAtributte.Value = Cells(i, 2)
            Debug.Print TypeName(newAtribute.Value)
            Debug.Print newAtribute.Value
            Debug.Print TypeName(Cells(i, 2).Value)
            Debug.Print Cells(i, 2).Value
            Debug.Print TypeName("Integer")
            'If Cells(i, 2).Value = "String" Then newField.Text = StringID
            If StrComp(Cells(i, 2).Value, "Integer") = 0 Then Debug.Print "He entrado en el if"
            'If Cells(i, 2).Value = "Floating point number" Then newField.Text = FloatingPointNumberID
            'If Cells(i, 2).Value = "Boolean" Then newField.Text = BooleanID

这是调试出口:

String
Integer 
String
Integer 

我不知道为什么它不会进入if中。

0 个答案:

没有答案