vfp表单.docx
- 文档编号:13259735
- 上传时间:2023-06-12
- 格式:DOCX
- 页数:19
- 大小:787.20KB
vfp表单.docx
《vfp表单.docx》由会员分享,可在线阅读,更多相关《vfp表单.docx(19页珍藏版)》请在冰点文库上搜索。
vfp表单
例1:
输入一个除数,求1~300之间能被除数整除的数,并求出他们的和。
“开始”按钮代码:
a=val(thisform.text1.value)
fori=1to300
ifi%a=0
thisform.edit1.value=thisform.edit1.value+str(i,6)
thisform.text2.value=str(val(thisform.text2.value)+i)
endif
endfor
“清除”按钮代码:
thisform.text1.value=""
thisform.edit1.value=""
thisform.text2.value=""
例题2:
在文本框中输入文本,查找编辑框中是否存在。
“查找”按钮代码:
m=thisform.text1.text
n=at(alltrim(m),thisform.edit1.value)
ifn!
=0
thisform.edit1.selstart=n-1
thisform.edit1.sellength=len(alltrim(m))
else
messagebox("没有相匹配的单词")
endif
“退出”按钮代码:
thisform.release
例题3:
“查找”按钮代码:
m=thisform.text1.text
n=at(alltrim(m),thisform.edit1.value)
ifn!
=0
thisform.edit1.selstart=n-1
thisform.edit1.sellength=len(alltrim(m))
else
messagebox("没有相匹配的单词")
endif
“替换”按钮代码:
ifthisform.edit1.seltext=alltrim(thisform.text1.text)
thisform.edit1.seltext=alltrim(thisform.text2.text)
else
messagebox("没有选择需要置换的单词")
endif
例题4.1:
十进制整数转化二进制
“转化”按钮CLICK事件代码
m=thisform.text1.value
s=""
dowhilem!
=0
r=mod(m,2)
m=int(m/2)
s=alltrim(str(r))+s
enddo
thisform.text2.value=s
thisform.refresh
“清除”按钮CLICK事件代码
thisform.text1.value=0
thisform.text1.setfocus
thisform.text2.value=0
例题4.2十进制转化二进制
“转化”按钮代码:
z=thisform.text1.value
m=int(z)
n=z-m
s1=""
s2=""
dowhilem!
=0
r=mod(m,2)
m=int(m/2)
s1=alltrim(str(r))+s1
enddo
dowhilen!
=0
n=n*2
b=int(n)
s2=s2+alltrim(str(b))
n=n-b
enddo
s=s1+"."+s2
iflen(s1)=0
s="0."+s2
endif
iflen(s2)=0
s=s1
endif
thisform.text2.value=s
thisform.refresh
“清除”按钮代码:
thisform.text1.value=0
thisform.text2.value=0
thisform.text1.setfocus
例题5:
输入三个数,显示最大值,并判断奇偶性。
“判断”按钮代码:
a=val(thisform.text1.value)
b=val(thisform.text2.value)
c=val(thisform.text3.value)
max=a
ifmax
max=b
endif
ifmax max=c endif ifmax%2=0 thisform.optiongroup1.option2.value=1 thisform.optiongroup1.option1.value=0 else thisform.optiongroup1.option2.value=0 thisform.optiongroup1.option1.value=1 endif thisform.label3.caption=alltrim(str(max)) “退出”按钮代码: thisform.release 例题6: 数据环境 课程.dbf 属性设置: list1 firstelement 1 指定组合框或列表框控件中显示的第一个元素 multiselect .T. 指定用户能否在列表框控件中进行多重选定、以及如何进行多重选定 nember0felement 0 指定数组有多少数据项用来填充组合框或列表框控件中的列表部分 rowsource 课程.课程名 指定组合框或列表框控件中数据值的源 rowsourcetype 6-字段 指定控件中数据值的源的类型 list2 multiselect .T. 指定用户能否在列表框控件中进行多重选定、以及如何进行多重选定 rowsource 无 rowsourcetype 1-值 指定控件中数据值的源的类型 commandgroup1 buttoncount 4 指定一个命令按钮组或选项按钮组中的按钮个数 value 1 指定控件的当前状态 “commandgroup1”控件click事件代码 docase casemandgroup1.value=1 forn=1tothisform.list1.listcount ifthisform.list1.selected(n) thisform.list2.additem(thisform.list1.list(n)) endif endfor casethis.value=2 thisform.list2.clear forn=1tothisform.list1.listcount thisform.list2.additem(thisform.list1.list(n)) endfor casethis.value=3 forn=1tothisform.list2.listcount ifthisform.list2.selected(n) thisform.list2.removeitem(n) endif endfor casethis.value=4 thisform.list2.clear endcase “commandgroup1”控件中command1的destroy事件代码 forn=1tothisform.list1.listcount ifthisform.list1.selected(n) thisform.list2.additem(thisform.list1.list(n)) endif endfor 例题7: 设置字体 “form1”的load事件代码: publicchx chx=0 “加粗”check1的CLICK事件代码 n=iif(chx=0,.f.,.t.) ifn thisform.label1.fontbold=.t. else thisform.label1.fontbold=.f. endif “commandgroup1”控件click事件代码: docase casemandgroup1.value=1 thisform.label1.fontname="隶书" casethis.value=2 thisform.label1.fontname="华文行楷" casethis.value=3 thisform.label1.fontname="华文彩云" casethis.value=4 thisform.label1.fontname="华文新魏" endcase 例题8: 模拟石英钟 属性设置 interval 100 指定调用计时器事件的间隔,以毫秒为单位 “form1”控件的load事件代码: publicss,mm,hh,x,y,x2,y2,x3,y3,x4,y4 store0toss,mm,hh “form1”控件的init事件代码: x=thisform.width/2 y=thisform.height/2 thisform.fillcolor=rgb(128,128,255) thisform.circle(100,x,y) fori=1to12 x1=x+100*cos(i*3.14159/6) y1=y+100*sin(i*3.14159/6) thisform.fillcolor=rgb(255,188,255) thisform.circle(5,x1,y1) next “timer1”的timer事件代码: thisform.forecolor=rgb(128,128,255) x2=x+90*cos((ss-15)*3.14159/30) y2=y+90*sin((ss-15)*3.14159/30) thisform.line(x,y,x2,y2) ss=mod(ss+1,60) x2=x+90*cos((ss-15)*3.14159/30) y2=y+90*sin((ss-15)*3.14159/30) thisform.forecolor=rgb(255,0,0) thisform.line(x,y,x2,y2) ifss=0 thisform.forecolor=rgb(128,128,255) x3=x+70*cos((mm-15)*3.14159/30) y3=y+70*sin((mm-15)*3.14159/30) thisform.line(x,y,x3,y3) mm=mod(mm+1,60) thisform.forecolor=rgb(128,128,255) x4=x+60*cos((hh-3)*3.14159/6) y4=y+60*sin((hh-3)*3.14159/6) thisform.line(x,y,x4,y4) hh=hh+1/60 ifhh>=12 hh=0 endif endif x3=x+70*cos((mm-15)*3.14159/30) y3=y+70*sin((mm-15)*3.14159/30) THISFORM.forecolor=rgb(0,255,0) x4=x+60*cos((hh-3)*3.14159/6) y4=y+60*sin((hh-3)*3.14159/6) thisform.forecolor=rgb(0,0,0) thisform.line(x,y,x4,y4) 例题9: 输入三个数,对其排序 “排序”的CLICK事件代码: a=val(thisform.text1.value) b=val(thisform.text2.value) c=val(thisform.text3.value) ifa t=a a=b b=t endif ifa t=c c=a a=t endif ifb t=b b=c c=t endif thisform.label2.caption=str(c) thisform.label3.caption=str(b) thisform.label4.caption=str(a) 例题10: 闪烁的图片 属性设置 interval 100 指定调用计时器事件的间隔,以毫秒为单位 计时器Timer1的init事件代码 publiccc cc=-1 计时器Timer1的timer事件代码 cc=-cc ifcc=1 thisform.image1.visible=.t. else thisform.image1.visible=.f. endif 例题11: 数字时钟(按钮显示时间) 属性设置 interval 5 指定调用计时器事件的间隔,以毫秒为单位 计时器Timer1的timer事件代码 thisform.cmn.caption=time() 例题12: 表单显示时间 属性设置 interval 100 指定调用计时器事件的间隔,以毫秒为单位 计时器Timer1的timer事件代码 thisform.label1.caption=time() 例题13: 对XSDA.DBF表进行排序 数据环境 XSDA.DBF “选项按钮组”的CLICK事件代码 docase casethis.value=1 setorderto学号 casethis.value=2 setorderto出生日期 endcase thisform.refresh WelcomeTo Download! ! ! 欢迎您的下载,资料仅供参考!
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vfp 表单