用VB实现Excel条件下的文本格式化

用VB实现Excel条件下的文本格式化,excel,vb.net,vba,Excel,Vb.net,Vba,使用VB 2010, 我正在尝试将excel文件转换为VB,并且正在努力处理这个条件格式行,其中TextOperator:=xlContains) 我已经完成了其他大部分工作,例如Excel.XlFormatConditionType Dim r As Excel.Range R = oSheet.Range("A" & CStr(FirstEmptyInColA) & ":A" & CStr(lastRow)).SpecialCells(Excel.XlCellTyp

使用VB 2010, 我正在尝试将excel文件转换为VB,并且正在努力处理这个条件格式行,其中TextOperator:=xlContains)

我已经完成了其他大部分工作,例如Excel.XlFormatConditionType

Dim r As Excel.Range 
R = oSheet.Range("A" & CStr(FirstEmptyInColA) & ":A" & CStr(lastRow)).SpecialCells(Excel.XlCellType.xlCellTypeVisible)

          For A = 0 To UBound(AgentNames)

                BColour = BColour + 1
                If BColour > 10 Then BColour = 3
                With r
                    .FormatConditions.Add(Type:=Excel.XlFormatConditionType.xlTextString, String:=AgentNames(A), TextOperator:=xlContains)
                    .FormatConditions(r.FormatConditions.Count).SetFirstPriority()
                    With .FormatConditions(1)
                        .Interior.PatternColorIndex = oWorkbook.xlAutomatic
                        .Interior.ColorIndex = BColour
                        If BColour = 5 Or BColour = 7 Or BColour = 9 Then
                            .Font.ColorIndex = 2
                        End If
                    End With
                    .FormatConditions(1).StopIfTrue = False
                End With
            Next A
            r = Nothing

应为Excel.XlContainsOperator.xlContains

应为Excel.XlContainsOperator.xlContains

查看:

返回或设置XLContainesOperator枚举的一个常量,指定由条件格式规则执行的文本搜索

在这种情况下,您的代码将:

TextOperator:=Excel.XlContainsOperator.xlContains
请注意,您可以使用以下运算符:

查看:

返回或设置XLContainesOperator枚举的一个常量,指定由条件格式规则执行的文本搜索

在这种情况下,您的代码将:

TextOperator:=Excel.XlContainsOperator.xlContains
请注意,您可以使用以下运算符:


那么您想要的只是vb.net中TextOperator:=xlContains的等价物?它的意思是string.Contains()。你能详细解释一下你到底需要什么吗?我想你想要的是
textmoperator:=Excel.XlContainsOperator.xlContains
谢谢,伙计们,这正是我需要的,我看过很多例子,但它们似乎都使用与Excel相同的语法,但是我必须使用这个完整的语法,任何人都能解释一下吗?所以你想要的只是vb.net中的TextOperator:=xlContains的等价物?它的意思是string.Contains()。你能详细解释一下你到底需要什么吗?我想你想要的是
textmoperator:=Excel.XlContainsOperator.xlContains
谢谢伙计们,这正是我需要的,我看过很多例子,但它们似乎都使用与Excel相同的语法,但我必须使用这个语法。有人能解释完整的语法吗