还有,杨版:
'生成可见的列名称
Dim Cols,Vals as New List(of String)
Dim txt As String = "A" '加个A是为了便于替换
For Each c as Col in Args(0).Cols
If c.Visible = True
txt = txt & "," & c.name
End If
Next
txt = txt.Replace("A,","") '生成可见列名
'生成查询条件
Cols.AddRange(txt.Split(",")) '字段列表
Vals.AddRange(Args(1).Replace("'","''").Replace("*","[*]").Split(",")) '查询值列表并保证其有效
Dim flt As String = "A" '加个A是为了便于替换
Dim i as Integer = 0
For Each Val as String in Vals
If i < Cols.Count
flt = flt & " and " & Cols(i) & " like '*" & Val & "*'"
End If
end if
endif
i = i + 1
Next
flt = flt.Replace("A and ","")
Return flt
这段代码,
但要注意,二楼的代码只能对字符型的列进行查询。如果你的列中有其它数据类型,
需要在 If i < Cols.Count 里进行判断。如:
If Args(0).Cols(i).DataCol.IsNumeric '如果是数值型
If Ars(0).Cols(i).DataCol.IsDate '如果是日期型,等等。否则会出错的。
这个怎么加?