请问在vb中如何将字符串中的内容提出来作为条件放在where后边

来源:百度知道 编辑:UC知道 时间:2024/05/28 09:37:50
需要作一个大型的模糊查询,以下仅为简单的例子:
dim cc as string
dim a as Integer
Private Sub Command1_Click()
cc="a>3"
if (通过什么可以使得a>3放到if 后) then
....
endif

end sub
程序中的条件为组合式的字符串,很长!最好有一种可以将字符串中的表达式提出来的方法
哪位高手可以帮一下啊

if a>3 then
....
end if

即使提出来依然是字符串,你是想做动态条件
只能把它拆开
比如说`"a>3" => "a", ">", "3"
strA = "a"
strB = "3"
condition = ">"
If condition = ">" Then
If strA > strB Then
.
.
.
.

首先你要清楚if ... then中间是条件,类型为逻辑值,而你cc变量是一个字符串,所以不要这样做。你可以将cc定义为逻辑值,如:
if a>3 then cc=true
if cc then ...