级《vfp程序设计》练习表单题部分表单题参考答案.docx
《级《vfp程序设计》练习表单题部分表单题参考答案.docx》由会员分享,可在线阅读,更多相关《级《vfp程序设计》练习表单题部分表单题参考答案.docx(34页珍藏版)》请在冰豆网上搜索。
级《vfp程序设计》练习表单题部分表单题参考答案
2008级《VFP程序设计》练习(表单题部分)
一、表单设计
230100、LOGIN.scx
######
formForm1
AutoCenter=.T.
Caption="登录"
######
labelLabel1
AutoSize=.T.
Caption="密码"
######
labelLabel2
AutoSize=.T.
Caption="登录日期"
######
textboxText1
InputMask="999999"
PasswordChar="*"
######
textboxText2
BorderStyle=0
Value=(DATE())
ReadOnly=.T.
BackColor=192,192,192
######
commandbuttonCommand1
Caption="确定"
######
commandbuttonCommand2
Caption="取消"
######
230101、shape.scx
######
formForm1
Caption="画图"
######
shapeShape1
Height=100
Width=70
Top=20
Left=30
BorderColor=255,0,0
######
commandCommand1
Caption="画图"
######
commandCommand2
Caption="退出"
######
230102、line.scx
######
formForm1
Caption="图形"
######
shapeShape1
Height=100
Width=100
BorderWidth=6
Curvature=99
BackColor=255,0,255
BorderColor=255,255,0
######
lineLine1
BorderWidth=20
BorderColor=0,0,255
######
230103、imsh2.scx
######
formForm1
BackColor=200,255,255
######
labelLabel1
FontName="隶书"
FontSize=18
BackStyle=0
Caption="日落"
ForeColor=0,0,255
######
imageImage1
Picture=..\..\fjexam95\sunset.jpg
Stretch=1
######
230104、sjrq2.scx
######
formForm1
Caption="显示时间与日期"
######
pageframePageframe1
PageCount=2
Page1.Caption="时间"
Page2.Caption="日期"
######
labellabel1
FontSize=14
Caption=(time())
######
labellabel2
FontBold=.T.
Caption=(dtoc(date()))
######
230105、shpr.scx
######
formForm1
Caption="形状变化"
######
labelLabel1
FontSize=12
Caption="圆角曲率"
######
spinnerSpinner1
KeyboardHighValue=99
KeyboardLowValue=0
SpinnerHighValue=99.00
SpinnerLowValue=0.00
######
shapeShape1
BackColor=255,0,0
######
230106、horse.scx
######
labelLabel1
Caption="哈哈镜"
AutoSize=.T.
FontSize=20
######
imageImage1
Picture=..\..\fjexam95\zebra.bmp
Stretch=2
Height=120
Width=80
######
230107、Selball2.scx
######
formForm1
AutoCenter=.T.
Caption="选择"
######
optiongroupOptiongroup1
ButtonCount=3
Option1.Caption="选1号"
Option2.Caption="选2号"
Option3.Caption="选3号"
Option1.Top=5
Option2.Top=5
Option3.Top=5
######
commandgroupCommandgroup1
ButtonCount=2
Command1.Caption="确定"
Command2.Caption="取消"
Command1.Top=5
Command2.Top=5
######
230108、dxxz2.scx
######
formForm1
Caption="多项选择"
######
checkCheck1
Caption="选择1"
AutoSize=.T.
######
checkCheck2
Caption="选择2"
AutoSize=.T.
######
commandgroupCommandgroup1
Command1.Caption="确定"
Command2.Caption="取消"
######
230109、combo.scx
######
formForm1
Caption="选择"
######
labelLabel1
Caption="请选择"
######
comboboxCombo1
RowSourceType=1
RowSource="VB,VFP,C语言"
######
checkboxCheck1
Caption="总成绩"
######
checkboxCheck2
Caption="平均成绩"
######
230110、edit.scx
######
formForm1
Caption="显示"
######
editboxEdit1
FontName="楷体"
Alignment=2
Value=居中显示
######
textboxText1
Value=(date())
FontBold=.T.
ForeColor=100,0,100
BackColor=200,200,255
######
二、表单编程
230200、lbtjsc.scx
参考解答:
●对象command1(添加按钮)的click事件
a=thisform.text1.value
thisform.list1.additem(a)
●对象command2(删除按钮)的click事件
fori=thisform.list1.listcountto1step-1
ifthisform.list1.selected(i)
thisform.list1.removeitem(i)
endif
endfor
230201、ddcx.scx
参考解答:
●设置对象text1的value属性为“=date()”
●对象command1(查询按钮)的click事件
rq=thisform.text1.value
thisform.grid1.recordsource="sele订单号,签订日期,金额fromorders;
where签订日期<=rqintocursorls"
thisform.refresh
230202、xscx.scx
参考解答:
●对象command1(查询按钮)的click事件
a=alltrim(bo1.value)
b=alltrim(bo2.value)
thisform.grid1.recordsource="selectxsb.商品号,商品名,上半年利润,下半年利润,上半年利润+下半年利润fromxsb,spdmb;
wherexsb.商品号=spdmb.商品号and部门号=aand年度=bintocursorlsb"
thisform.refresh
230203、login2.scx
参考解答:
●对象command1(确定按钮)的click事件
xh=alltrim(bo1.value)
mm=alltrim(thisform.text1.value)
select姓名fromstulogwherealltrim(学号)==xhandalltrim(密码)==mmintocursorlsb
thisform.label3.visible=.t.
selelsb
ifreccount()=0
thisform.label3.caption="密码错误"
else
gotop
thisform.label3.caption="欢迎"+alltrim(姓名)+"同学"
endif
thisform.refresh
230204、adds.scx
参考解答:
●对象command1(统计按钮)的click事件
replall金额with单价*数量
thisform.refresh
●对象check1(复选框)的click事件
ifthis.value=1
mand1.enabled=.t.
else
mand1.enabled=.f.
endif
230205、gspf.scx
参考解答:
●对象combo1(选择歌手姓名组合框)的interactivechange事件
a=alltrim(this.value)
thisform.grid1.recordsource="select评委编号,分数fromgsb,pfb;
wheregsb.歌手编号=pfb.歌手编号andalltrim(歌手姓名)=aintocursorlsb"
selectavg(分数)fromlsbintoarrayabc
thisform.text1.value=abc(1,1)
thisform.refresh
230206、tsxz.scx
参考解答:
●对象optiongroup1的click事件
seleavg(单价),sum(数量)frombook1where种类=bo1.valueintoarraysz
ifthis.value=1
thisform.text1.value=sz(1,1)
else
thisform.text1.value=sz(1,2)
endif
thisform.refresh
230207、ddpx.scx
参考解答:
●对象command1(生成表按钮)的click事件
ifthisform.optiongroup1.value=1
sele职员号,avg(金额)as平均金额fromordersgroupby职员号;
orderby平均金额intotablepx_a
else
sele职员号,avg(金额)as平均金额fromordersgroupby职员号;
orderby平均金额descintotablepx_b
endif
230208、ddtj.scx
参考解答:
●对象command1(统计按钮)的click事件
ifthisform.optiongroup1.value=1
thisform.grid1.recordsource="select客户号,count(订单号),sum(金额);
fromordersgroupby客户号intocursorls"
endif
ifthisform.optiongroup1.value=2
thisform.grid1.recordsource="select职员号,count(订单号),sum(金额);
fromordersgroupby职员号intocursorls"
endif
thisform.refresh
230209、rccx.scx
参考解答:
●对象command1(显示按钮)的click事件
bh=bo1.value
thisform.list1.rowsource="sele姓名,成果名称,成果类别fromrcda,cjda;
wherercda.人才编号=cjda.人才编号andrcda.人才编号=bhintocursorls"
thisform.refresh
230210、teach1.scx
参考解答:
●对象combo1的init事件
this.listindex=1
●对象combo1的click事件
seleavg(基本工资)fromddm1,teach1whereddm1.系号=teach1.系号;
and系名=this.valueintoarraya
ifthisform.check1.value=0
thisform.text1.value=""
else
thisform.text1.value=a(1,1)
endif
thisform.refresh
230300、calchar.scx
参考解答:
●对象command1(统计按钮)的click事件
t=0
a=thisform.text1.value
fori=1tolen(a)
x=substr(a,i,1)
ifx!
=space
(1)
t=t+1
endif
endfor
thisform.text2.value=t
230301、chadate.scx
参考解答:
●对象text1的value值改为“=date()”
●对象spinner1的upclick事件
thisform.text1.value=thisform.text1.value-1
thisform.refresh
●对象spinner1的downclick事件
thisform.text1.value=thisform.text1.value+1
thisform.refresh
230302、js2.scx
参考解答:
●对象command1(计算按钮)的click事件
a=thisform.text1.value
b=thisform.text2.value
ifbo1.value="+"
c=a+b
endif
ifbo1.value="-"
c=a-b
endif
ifbo1.value="*"
c=a*b
endif
ifbo1.value="/"
ifb<>0
c=a/b
else
c="除数不能为0"
endif
endif
thisform.text3.value=c
230303、calc.scx
参考解答:
●对象command1(计算按钮)的click事件
x=thisform.text1.value
docase
casex<=-10
y=2*(sin(x)+1)
casex<=10
y=(abs(x)-5)/3
otherwise
y=x/7-8
endcase
thisform.text2.value=y
230304、xsys.scx
参考解答:
●对象command1(更新按钮)的click事件
r=thisform.spinner1.value
g=thisform.spinner2.value
b=thisform.spinner3.value
thisform.shape1.backcolor=rgb(r,g,b)
ifr=255andg=0andb=0
thisform.shape1.curvature=0
else
ifr=0andg=255andb=0
thisform.shape1.curvature=50
else
ifr=0andg=0andb=255
thisform.shape1.curvature=99
else
thisform.shape1.curvature=1
endif
endif
endif
thisform.refresh
230305、stfn.scx
参考解答:
●对象command1(偶数字符串按钮)的click事件
s=alltrim(thisform.text1.value)
n=len(s)
js=””
fori=1ton
c=substr(s,i,1)
ifc>="0"andc<="9"
d=val(c)
ifd%2=0
js=js+c
endif
endif
endfor
thisform.text2.value=js
thisform.refresh
230306、addcal.scx
参考解答:
●对象command1(添加按钮)的click事件
s=thisform.text1.value
n=str(len(s))
a=s+space
(1)+alltrim(n)
thisform.list1.additem(a)
thisform.text1.setfocus
230307、SelPag.SCX
参考解答:
●对象page1(天空页)的click事件
this.backcolor=rgb(0,0,255)
thisform.refresh
●对象page2(沙漠页)的click事件
this.backcolor=rgb(255,255,0)
thisform.refresh
●对象page3(雪原页)的click事件
this.backcolor=rgb(255,255,255)
thisform.refresh
230308、leapyear.scx
参考解答:
●对象command1(是否闰年按钮)的click事件
y=year(thisform.text1.value)
if(y%4=0andy%100!
=0)ory%400=0
thisform.text2.value="是闰年"
else
thisform.text2.value="不是闰年"
endif
thisform.refresh
230309、factor.scx
参考解答:
●对象command1(因子个数按钮)的click事件
n=thisform.text1.value
js=0
fori=1ton-1
ifn%i=0
js=js+1
endif
endfor
thisform.text2.value=js
thisform.refresh
230310、stat.scx
参考解答:
●对象command1(数字字符个数按钮)的click事件
s=alltrim(thisform.text1.value)
n=len(s)
js=0
fori=1ton
c=substr(s,i,1)
ifc>="0"andc<="9"
js=js+1
endif
endfor
thisform.text2.value=js
thisform.refresh