vfp二级设计题答案.docx

上传人:b****6 文档编号:7649108 上传时间:2023-05-11 格式:DOCX 页数:15 大小:1.50MB
下载 相关 举报
vfp二级设计题答案.docx_第1页
第1页 / 共15页
vfp二级设计题答案.docx_第2页
第2页 / 共15页
vfp二级设计题答案.docx_第3页
第3页 / 共15页
vfp二级设计题答案.docx_第4页
第4页 / 共15页
vfp二级设计题答案.docx_第5页
第5页 / 共15页
vfp二级设计题答案.docx_第6页
第6页 / 共15页
vfp二级设计题答案.docx_第7页
第7页 / 共15页
vfp二级设计题答案.docx_第8页
第8页 / 共15页
vfp二级设计题答案.docx_第9页
第9页 / 共15页
vfp二级设计题答案.docx_第10页
第10页 / 共15页
vfp二级设计题答案.docx_第11页
第11页 / 共15页
vfp二级设计题答案.docx_第12页
第12页 / 共15页
vfp二级设计题答案.docx_第13页
第13页 / 共15页
vfp二级设计题答案.docx_第14页
第14页 / 共15页
vfp二级设计题答案.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

vfp二级设计题答案.docx

《vfp二级设计题答案.docx》由会员分享,可在线阅读,更多相关《vfp二级设计题答案.docx(15页珍藏版)》请在冰点文库上搜索。

vfp二级设计题答案.docx

vfp二级设计题答案

使用说明

练习这些题,可以在“表单”文件夹进行。

打开vfp后,用“setdefato路径”命令设置路径到“表单”文件夹之后,在vfp中

打开,文件类型选:

表单(如图)

即可找到题目中所涉及的表单。

08年06月题

提示:

作为设计题的第2题,一般地,做题前可以先试运行表单,其次要查看并了解数据环境中的表。

&&表格显示的数据由2个属性决定:

recordsourceType和recordsource

&&注意到recordsourceType已经设置为4-查询,这里只需要设置recordsource属性即可

bmh=alltrim(thisform.text1.value)

nd=alltrim(thisform.text2.value)

thisform.grid1.recordsource="selectxsb.商品号,商品名,上半年利润,;

下半年利润,上半年利润+下半年利润fromxsb,spdmb;

wherexsb.商品号=spdmb.商品号and;

部门号=bmhand年度=ndintocursortmp"

thisform.refresh

ifthisform.optiongroup1.value=1

select职员号,avg(金额)as平均金额fromorders;

groupby职员号orderby2intotablepx_a

else

select职员号,avg(金额)as平均金额fromorders;

groupby职员号orderby2descintotablepx_d

endif

ifthisform.optiongroup1.value=1

thisform.grid1.recordsource="select客户号,count(*),;

sum(金额)fromordersgroupby客户号;

intocursortmp"

endif

ifthisform.optiongroup1.value=2

thisform.grid1.recordsource="select职员号,count(*),;

sum(金额)fromordersgroupby职员号;

intocursortmp"

endif

gsbh=gsb.歌手编号

dimeaa(1,6)&&定义一个1行6列的二维数组

select分数frompfborderby评委编号;

where歌手编号=gsbhintoarrayaa

ss=0

fori=1to6

attname="thisform.text"+alltrim(str(i))+".value"

&attname=aa(1,i)

ss=ss+aa(1,i)

endfor

thisform.text7.value=ss/6

1)设置combo1的value属性为:

=ddm1.系名

2)组合框的interactivechange事件编写代码如下:

dimeaa

(1)

ifthisform.check1.value=1

selectavg(基本工资)fromteach1;

where系号=ddm1.系号intoarrayaa

thisform.text1.value=aa

(1)

else

thisform.text1.value=""

endif

&&list1的rowsourceType已经设置为“3-SQL”,columncount为3,故:

thisform.list1.rowsource="select姓名,成果名称,成果类别;

Fromrcda,cjda;

wherercda.人才编号=cjda.人才编号and;

rcda.人才编号=bo1.value;

intocursortmp"

&&建议用结构清晰的三个独立的if语句。

&&注意到text1和text2都为数值型文本框

x=thisform.text1.value

ifx<10

y=x/3

endif

ifx>=10andx<20

y=2*x+1

endif

ifx>=20

y=3*x-10

endif

thisform.text2.value=y

&&判断一个字符ch是否数字字符,只需判断这个字符的ASCII码

&&是否处于"0"到"9"的ASCCII码之间,而字符ch的ASCII码可以用ASC(ch)获得

&&本程序的思路是:

把text1中的字符按顺序逐个取出并判断是否数字字符。

&&如果不是是,连接到text2之后

aa=alltrim(thisform.text1.value)

bb=""&&bb初始为空字符串

lth=len(aa)

fori=1tolth

ch=substr(aa,i,1)&&取出aa的第i个字符

ifasc(ch)asc("9")&&如果不是数字字符

bb=bb+ch&&连接

endif

endfor

thisform.text2.value=bb

yy=year(thisform.text1.value)

ifyy%4=0andyy%100!

=0oryy%400=0

res="是闰年"

else

res="不是闰年"

endif

thisform.text2.value=res

&&此题用到宏替换函数:

"&",详见课本第3章的字符型函数。

&&注意到四个文本框的数据类型,其中text2为字符型,其他为数值型。

x=thisform.text1.value

op=alltrim(thisform.text2.value)

y=thisform.text3.value

ifop="+"orop="-"orop="*"or(op="/"andy!

=0)

res=x&opy&&以op="*"为例,此命令相当于:

res=x*y

else

res="非法计算"

endif

thisform.text4.value=res

txt=alltrim(thisform.text1.value)

lth=str(len(txt))

thisform.list1.additem(txt)

thisform.list2.additem(lth)

&&注意到text1已经是数值型

&&计算数n的因子个数,本程序把从1到n-1之间的每个数都测试是否能整除n

&&若是,则为因子,那么计数器变量ct就增1

n=thisform.text1.value

ct=0

fori=1ton-1&&i为1到n-1之间的数

ifn%i=0&&如果n能被i整除

ct=ct+1&&计数器变量增1

endif

endfor

thisform.text2.value=ct

08年12月新题

&&此题与本文中的第一题几乎是一样的

bmh=alltrim(bo1.value)

nd=alltrim(bo2.value)

thisform.grid1.recordsource="selectxsb.商品号,商品名,上半年利润,;

下半年利润,上半年利润+下半年利润fromxsb,spdmb;

wherexsb.商品号=spdmb.商品号and;

部门号=bmhand年度=ndintocursortmp"

thisform.refresh

在”允许统计”的click事件编写:

ifthis.value=1

mand1.enabled=.t.

else

mand1.enabled=.f.

endif

在”统计”按钮的click事件编写:

replaceall金额with单价*数量

thisform.refresh

&&在组合框的interactivechange或者click事件编写代码:

thisform.grid1.columncount=2

thisform.grid1.recordsourcetype=4

thisform.grid1.recordsource="select评委编号,分数frompfb;

where歌手编号=gsb.歌手编号intocursortmp"

&&以上查询语句中,注意到"歌手编号=gsb.歌手编号"这个式子

&&其中,由于gsb表的姓名绑定到组合框上,所以,组合框的选择会导致gsb表当前

&&记录的改变,此时,gsb表的歌手编号字段值也会随之而变

selecttmp

dimeaa

(1)&&定义一个数组,用来保存查询结果

selectavg(分数)fromtmpintoarrayaa

thisform.text1.value=aa

(1)

thisform.refresh

在属性窗口中,设置text1控件的value属性为:

=date()

编写按钮的click事件代码如下:

dd=thisform.text1.value

thisform.grid1.recordsourcetype=4

thisform.grid1.columncount=3

thisform.grid1.recordsource="select订单号,签订日期,金额;

fromorderswhere签订日期<=ddintocursortmp"

thisform.refresh

编写选择按钮组的interactivechange或click事件代码如下:

settalkoff

ipt=bo1.value

ifthis.value=1

average单价tores

endif

ifthis.value=2

sum数量tores

endif

thisform.text1.value=res

ipt=alltrim(thisform.text1.value)&&获取输入的字符串

ln=len(ipt)&&计算字符串长度

res=""&&令res为空字符串

fori=1toln

ch=substr(ipt,i,1)&&取出第i个字符

ifasc(ch)>=asc("0")andasc(ch)<=asc("9");&&用ascII码判断该字符是否数字字符

andval(ch)%2=0&&判断是否偶数

res=res+ch&&若是,连接到res后面

endif

endfor

thisform.text2.value=res&&把结果显示在text2上

&&根据运算符的取值分为四种情况,其中运算符为“/”又可分为两种情况(y是否为0)

x=thisform.text1.value

y=thisform.text2.value

op=bo1.value

ifop="+"

r=x+y

endif

ifop="-"

r=x-y

endif

ifop="*"

r=x*y

endif

ifop="/"

ify!

=0

r=x/y

else

r="除数不能为0"

endif

endif

thisform.text3.value=r

inp=alltrim(thisform.text1.value)

ln=len(inp)

opt=inp+""+alltrim(str(ln))&&连接,""为一个空格字符;ln是数值型,必须转换为字符型

thisform.list1.additem(opt)&&添加列表框的项

thisform.text1.setfocus()&&设置文本获得焦点

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2