在if条件中是不是不能用like做模糊查询!急!!!
conn.Open "qxd "
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "select * from orecord where 1=1 " & strtime & " and 相关机构 like '% " & rst1(0) & "% ' ", conn, , , adCmdText
rst.MoveFirst
For i = 0 To rst.RecordCount - 1
n = rst.RecordCount
If rst.Fields(6) = "电视机 " Then
a = a + 1
ElseIf rst.Fields(6) = "空调 " Then
b = b + 1
ElseIf rst.Fields(6) = "冰箱 " Then
c = c + 1
ElseIf rst.Fields(6) = "洗衣机 " Then
d = d + 1
ElseIf rst.Fields(6) = "渣堵 " Then
e = e + 1
ElseIf rst.Fields(6) Like " '%数码% ' " Then
k = k + 1
ElseIf rst.Fields(6) Like " '%其他% ' " Then
l = l + 1
End If
rst.MoveNext
Next i
rst.Close
conn.Close
在这段程序中:
rst.Fields(6) Like " '%数码% ' " 和
rst.Fields(6) Like " '%其他% ' " 这样用like语句是不是不对,
因为起不了作用,k和l的数值都是0
[解决办法]
if instr(1,rst.Fields(6), "数码 ")> 0 then k=k+1
[解决办法]
VB没有LIKE这个关键字的
要用instr函数来判断 就像楼上的那样