小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

看實(shí)例學(xué)VFP:模糊查詢

 happyngkmw 2012-09-08

看實(shí)例學(xué)VFP:模糊查詢

時(shí)間:2009-02-11 本站 老馬
-

本文是在vfp中使用select語(yǔ)句的like子句的一個(gè)例子,關(guān)于like子句請(qǐng)參考:select SQL 命令sql語(yǔ)言教程

本例運(yùn)行時(shí)如下圖:

本例用到了“數(shù)據(jù)1”數(shù)據(jù)庫(kù)中的“網(wǎng)站信息表”,關(guān)于該數(shù)據(jù)庫(kù)的情況已經(jīng)在看實(shí)例學(xué)VFP:示例數(shù)據(jù)庫(kù)一文中給出,這里不再詳述。
 

制作步驟如下:

一、新建表單form1,并將其caption屬性值設(shè)為“模糊查詢”,width屬性值設(shè)置為290,height屬性值設(shè)置為175,AutoCenter屬性值設(shè)置為.t.,并將其保存為“模糊查詢.scx”。

二、向表單添加一個(gè)grid控件,并將其width屬性值設(shè)置為290,height屬性值設(shè)置為100。

三、在grid控件的下方添加兩個(gè)label控件,將它們的caption屬性值分別設(shè)置為“請(qǐng)選擇查找方式”和“請(qǐng)輸入要查找的內(nèi)容”。

四、在label控件的下方添加一個(gè)組合框控件Combo1和一個(gè)文本框控件,并將組合框控件的RowSourceType屬性值設(shè)置為“1-值”,RowSource屬性值設(shè)置為“編號(hào),網(wǎng)站名稱,網(wǎng)站網(wǎng)址”。

五、在文本框的右側(cè)再添加兩個(gè)命令按鈕command1和command2,并將command1和command2的caption屬性值分別設(shè)置為“查找”和“恢復(fù)”。

六、對(duì)表單上各控件的位置進(jìn)行適當(dāng)?shù)恼{(diào)整,調(diào)整后的表單設(shè)計(jì)器如下圖:

七、添加事件代碼:

(一)表單的unload事件:close data

(二)表單的init事件:

use 網(wǎng)站信息表
this.Combo1.value="編號(hào)"
with thisform.grid1
    .recordsource="網(wǎng)站信息表"
    .deletemark=.f.
    .visible=.t.
.readonly=.t. .ColumnCount=3 .Column1.Header1.Caption="編號(hào)" .Column1.Header1.BackColor=RGB(255,255,190) .Column2.Header1.BackColor=RGB(255,255,190) .Column2.Header1.Caption="網(wǎng)站名稱" .Column3.Header1.BackColor=RGB(255,255,190) .Column3.Header1.Caption="網(wǎng)站網(wǎng)址" .Column1.width=75 .Column2.width=80 .Column3.width=150 endwith thisform.grid1.Setall("DynamicBackColor","RGB(224,225,255)","Column")

(三)“查找”按鈕(command1)的click事件:

if empty(thisform.Text1.value)=.f.
go top
a=thisform.Combo1.value
b=alltrim(thisform.Text1.value)
local c as integer
  if a="編號(hào)"
     Select * from 網(wǎng)站信息表 where 編號(hào) like b +"%" into cursor 臨時(shí)網(wǎng)站信息表
     sele 臨時(shí)網(wǎng)站信息表
     c=reccount()
     if c<1
       use
       messagebox("數(shù)據(jù)庫(kù)中不存在您所要查詢的記錄",16,"系統(tǒng)提示")
       thisform.command2.click()
       return
     endif
  endif
  if a="網(wǎng)站名稱"
     Select * from 網(wǎng)站信息表 where 網(wǎng)站名稱 like b +"%" into cursor 臨時(shí)網(wǎng)站信息表
     sele 臨時(shí)網(wǎng)站信息表
     c=reccount()
     if c<1
       use
       messagebox("數(shù)據(jù)庫(kù)中不存在您所要查詢的記錄",16,"系統(tǒng)提示")
       thisform.command2.click()
       return
     endif
  endif
  if a="網(wǎng)站網(wǎng)址"
     Select * from 網(wǎng)站信息表 where 網(wǎng)站網(wǎng)址 like b +"%" into cursor 臨時(shí)網(wǎng)站信息表
     sele 臨時(shí)網(wǎng)站信息表
     c=reccount()
     if c<1
       use
       messagebox("數(shù)據(jù)庫(kù)中不存在您所要查詢的記錄",16,"系統(tǒng)提示")
       thisform.command2.click()
       return
     endif
  endif
  with thisform.grid1
    .width=350
    .height=100
    .left=10
    .recordsource="臨時(shí)網(wǎng)站信息表"
    .deletemark=.f.
    .visible=.t.
    .readonly=.t.
    .ColumnCount=3
    .Column1.Header1.Caption="編號(hào)"
    .Column1.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.Caption="網(wǎng)站名稱"
    .Column3.Header1.BackColor=RGB(255,255,190)
    .Column3.Header1.Caption="網(wǎng)站網(wǎng)址"
    .Column1.width=75
    .Column2.width=80
    .Column3.width=150
  endwith
  thisform.grid1.Setall("DynamicBackColor","RGB(224,225,255)","Column")
  thisform.grid1.setfocus
else
  messagebox("請(qǐng)輸入要查找的內(nèi)容!",16,"系統(tǒng)提示")
  thisform.Text1.value=""
  thisform.Text1.Setfocus
endif

(四)“恢復(fù)”按鈕(command2)的click事件:

sele 網(wǎng)站信息表
go top
thisform.Text1.value=""
thisform.Text1.Setfocus
with thisform.grid1
    .width=350
    .height=100
    .left=10
    .recordsource="網(wǎng)站信息表"
    .visible=.t.
    .readonly=.t.
    .ColumnCount=3
    .Column1.Header1.Caption="編號(hào)"
    .Column1.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.BackColor=RGB(255,255,190)
    .Column2.Header1.Caption="網(wǎng)站名稱"
    .Column3.Header1.BackColor=RGB(255,255,190)
    .Column3.Header1.Caption="網(wǎng)站網(wǎng)址"
    .Column1.width=75
    .Column2.width=80
    .Column3.width=150
endwith
thisform.grid1.Setall("DynamicBackColor","RGB(224,225,255)","Column")
thisform.refresh

八、運(yùn)行“模糊查詢.scx”。

參考資料:

vfp基礎(chǔ)教程:http:///vfpjc/index0.htm

vfp初級(jí)教程:http:///cc/index.htm

vfp中級(jí)教程:http:///mcc/mcc.htm

vfp高級(jí)教程:http:///hcc/hcc.htm

VFP網(wǎng)絡(luò)開(kāi)發(fā):http:///VFPwz/vfpwlkf.htm

vfp調(diào)用api函數(shù):http:///VFPwz/vfpapi.htm

VFP報(bào)表打?。篽ttp:///VFPwz/vfpreport.htm

VFP常用技術(shù):http:///VFPwz/vfpcyjs.htm

VFP經(jīng)驗(yàn)匯總:http:///VFPwz/vfpjyhz.htm

VFP控件使用:http:///VFPwz/vfpkjsy.htm

VFP數(shù)據(jù)處理:http:///VFPwz/vfpsjcl.htm

本例代碼在Win2003+VFP6.0環(huán)境下調(diào)試通過(guò)。

查看全套“菜鳥(niǎo)也學(xué)VFP”教程

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多