主题:[原创]完整查询并精确定位实例
查询在有些数据系统中,无法用VF提供的简单指令或函数来完成,为此应编写自己的执行代码。比如在字符ABCDEF中,要查找“123”的字样,由于“123”可能在最前面,也可能在最后面,或是在中间的某个位置。现提供一个类似这样的实例,供诸位参考。
如图示,代码的编写过程如下(修复后的代码):
Local _Aa
_Aa=Alltri(Upper(thisform.Yspagefrm1.page5.ystxtbx1.value))
If Chaxun=1
Sele gljcx
Repl chx with "" for recno()>0
SELECT * FROM gljcx WHERE _Aa$gljmc INTO TABLE Lscx
Sele Lscx
Go TOP
ELSE
Sele Lscx
If Not Eof()
Go Chaxun
Endif
ENDIF
DO WHILE .T.
IF EOF()
Thisform.Yspagefrm1.page5.Yscmdbtn1.Caption="查询完毕"
EXIT
Else
Thisform.Yspagefrm1.page5.Yscmdbtn1.Caption="继续查询"
ENDIF
SELE GLJCX
LOCATE FOR Alltri(GLJMC)==ALLTRI(Lscx.gljmc)
IF FOUND()
Repl chx with "OK"
Sele Lscx
SKIP
Chaxun=recno()
EXIT
Else
SELE Lscx
SKIP
Chaxun=recno()
LOOP
Endif
ENDDO
Thisform.Yspagefrm1.page5.Grid1.Refresh
如图示,代码的编写过程如下(修复后的代码):
Local _Aa
_Aa=Alltri(Upper(thisform.Yspagefrm1.page5.ystxtbx1.value))
If Chaxun=1
Sele gljcx
Repl chx with "" for recno()>0
SELECT * FROM gljcx WHERE _Aa$gljmc INTO TABLE Lscx
Sele Lscx
Go TOP
ELSE
Sele Lscx
If Not Eof()
Go Chaxun
Endif
ENDIF
DO WHILE .T.
IF EOF()
Thisform.Yspagefrm1.page5.Yscmdbtn1.Caption="查询完毕"
EXIT
Else
Thisform.Yspagefrm1.page5.Yscmdbtn1.Caption="继续查询"
ENDIF
SELE GLJCX
LOCATE FOR Alltri(GLJMC)==ALLTRI(Lscx.gljmc)
IF FOUND()
Repl chx with "OK"
Sele Lscx
SKIP
Chaxun=recno()
EXIT
Else
SELE Lscx
SKIP
Chaxun=recno()
LOOP
Endif
ENDDO
Thisform.Yspagefrm1.page5.Grid1.Refresh