2008级《VFP程序设计》练习(表单题部分)一、表单设计230100、LOGIN.scx######form Form1AutoCenter = .T.Caption = "登录"######label Label1AutoSize = .T.Caption = "密码"######label Label2AutoSize = .T.Caption = "登录日期"######textbox Text1InputMask = "999999"PasswordChar = "*"######textbox Text2BorderStyle = 0Value = (DATE( ))ReadOnly = .T.BackColor = 192,192,192######commandbutton Command1 Caption = "确定"######commandbutton Command2 Caption = "取消"######230101、shape.scx######form Form1Caption = "画图"######shape Shape1Height = 100Width = 70Top = 20Left = 30BorderColor = 255,0,0######command Command1 Caption = "画图"######command Command2 Caption = "退出"######230102、line.scx######form Form1Caption = "图形"######shape Shape1Height = 100Width = 100 BorderWidth = 6 Curvature = 99 BackColor = 255,0,255 BorderColor = 255,255,0 ######line Line1 BorderWidth = 20 BorderColor = 0,0,255 ######230103、imsh2.scx######form Form1BackColor = 200,255,255######label Label1FontName = "隶书"FontSize = 18BackStyle = 0Caption = "日落"ForeColor = 0,0,255######image Image1Picture = ..\..\fjexam95\sunset.jpg Stretch = 1######230104、sjrq2.scx######form Form1Caption = "显示时间与日期" ######pageframe Pageframe1 PageCount = 2Page1.Caption = "时间" Page2.Caption = "日期"######label label1FontSize = 14Caption = (time())######label label2FontBold = .T.Caption = (dtoc(date()))######230105、shpr.scx######form Form1Caption = "形状变化"######label Label1FontSize = 12Caption = "圆角曲率"######spinner Spinner1 KeyboardHighValue = 99 KeyboardLowValue = 0 SpinnerHighValue = 99.00 SpinnerLowValue = 0.00 ######shape Shape1 BackColor = 255,0,0######230106、horse.scx######label Label1Caption = "哈哈镜"AutoSize = .T.FontSize = 20######image Image1Picture = ..\..\fjexam95\zebra.bmp Stretch = 2Height = 120Width = 80######230107、Selball2.scx######form Form1AutoCenter = .T.Caption = "选择"######optiongroup Optiongroup1 ButtonCount = 3Option1.Caption = "选1号" Option2.Caption = "选2号" Option3.Caption = "选3号" Option1.Top = 5Option2.Top = 5Option3.Top = 5######commandgroup Commandgroup1 ButtonCount = 2Command1.Caption = "确定" Command2.Caption = "取消" Command1.Top = 5Command2.Top = 5######230108、dxxz2.scx######form Form1Caption = "多项选择"######check Check1Caption = "选择1"AutoSize = .T.######check Check2Caption = "选择2"AutoSize = .T.######commandgroup Commandgroup1 Command1.Caption = "确定" Command2.Caption = "取消"######230109、combo.scx######form Form1Caption = "选择"######label Label1Caption = "请选择"######combobox Combo1 RowSourceType = 1 RowSource = "VB,VFP,C语言" ######checkbox Check1Caption = "总成绩"######checkbox Check2Caption = "平均成绩"######230110、edit.scx######form Form1Caption = "显示"######editbox Edit1FontName = "楷体_GB2312" Alignment = 2Value = 居中显示######textbox Text1Value = (date())FontBold = .T.ForeColor = 100,0,100 BackColor = 200,200,255######二、表单编程230200、lbtjsc.scx参考解答:●对象command1(添加按钮)的click事件a=thisform.text1.valuethisform.list1.additem(a)●对象command2(删除按钮)的click事件for i=thisform.list1.listcount to 1 step -1if thisform.list1.selected(i)thisform.list1.removeitem(i)endifendfor230201、ddcx.scx参考解答:●设置对象text1的value属性为“=date()”●对象command1(查询按钮)的click事件rq=thisform.text1.valuethisform.grid1.recordsource="sele 订单号,签订日期,金额from orders ;where 签订日期<=rq into cursor ls"thisform.refresh230202、xscx.scx参考解答:对象command1(查询按钮)的click事件a=alltrim(bo1.value)b=alltrim(bo2.value)thisform.grid1.recordsource="select xsb.商品号,商品名,上半年利润,下半年利润,上半年利润+下半年利润from xsb,spdmb ;where xsb.商品号=spdmb.商品号and 部门号=a and 年度=b into cursor lsb"thisform.refresh230203、login2.scx参考解答:●对象command1(确定按钮)的click事件xh=alltrim(bo1.value)mm=alltrim(thisform.text1.value)select 姓名from stulog where alltrim(学号)==xh and alltrim(密码)==mm into cursor lsb bel3.visible=.t.sele lsbif reccount()=0bel3.caption="密码错误"elsego topbel3.caption="欢迎"+alltrim(姓名)+"同学"endifthisform.refresh230204、adds.scx参考解答:●对象command1(统计按钮)的click事件repl all 金额with 单价*数量thisform.refresh●对象check1(复选框)的click事件if this.value=1mand1.enabled=.t.elsemand1.enabled=.f.endif230205、gspf.scx参考解答:对象combo1(选择歌手姓名组合框)的interactivechange事件a=alltrim(this.value)thisform.grid1.recordsource="select 评委编号,分数from gsb,pfb ;where gsb.歌手编号=pfb.歌手编号and alltrim(歌手姓名)=a into cursor lsb" select avg(分数) from lsb into array abcthisform.text1.value=abc(1,1)thisform.refresh230206、tsxz.scx参考解答:●对象optiongroup1的click事件sele avg(单价),sum(数量) from book1 where 种类=bo1.value into array sz if this.value=1thisform.text1.value=sz(1,1)elsethisform.text1.value=sz(1,2)endifthisform.refresh230207、ddpx.scx参考解答:●对象command1(生成表按钮)的click事件if thisform.optiongroup1.value=1sele 职员号,avg(金额) as 平均金额from orders group by 职员号;order by 平均金额into table px_aelsesele 职员号,avg(金额) as 平均金额from orders group by 职员号;order by 平均金额desc into table px_bendif230208、ddtj.scx参考解答:对象command1(统计按钮)的click事件if thisform.optiongroup1.value=1thisform.grid1.recordsource="select 客户号,count(订单号),sum(金额) ; from orders group by 客户号into cursor ls"endifif thisform.optiongroup1.value=2thisform.grid1.recordsource="select 职员号,count(订单号),sum(金额) ; from orders group by 职员号into cursor ls"endifthisform.refresh230209、rccx.scx参考解答:●对象command1(显示按钮)的click事件bh=bo1.valuethisform.list1.rowsource="sele 姓名,成果名称,成果类别from rcda,cjda ;where rcda.人才编号=cjda.人才编号and rcda.人才编号=bh into cursor ls" thisform.refresh230210、teach1.scx参考解答:●对象combo1的init事件this.listindex=1●对象combo1的click事件sele avg(基本工资) from ddm1,teach1 where ddm1.系号=teach1.系号; and 系名=this.value into array aif thisform.check1.value=0thisform.text1.value=""elsethisform.text1.value=a(1,1)endifthisform.refresh230300、calchar.scx参考解答:●对象command1(统计按钮)的click事件t=0a=thisform.text1.valuefor i=1 to len(a)x=substr(a,i,1)if x!=space(1)t=t+1endifendforthisform.text2.value=t230301、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.refresh230302、js2.scx参考解答:●对象command1(计算按钮)的click事件a=thisform.text1.valueb=thisform.text2.valueif bo1.value="+"c=a+bendifif bo1.value="-"c=a-bendifif bo1.value="*"c=a*bendifif bo1.value="/"if b<>0c=a/belsec="除数不能为0"endifendifthisform.text3.value=c230303、calc.scx参考解答:●对象command1(计算按钮)的click事件x=thisform.text1.valuedo casecase x<=-10y=2*(sin(x)+1)case x<=10y=(abs(x)-5)/3otherwisey=x/7-8endcasethisform.text2.value=y230304、xsys.scx参考解答:对象command1(更新按钮)的click事件r=thisform.spinner1.valueg=thisform.spinner2.valueb=thisform.spinner3.valuethisform.shape1.backcolor=rgb(r,g,b)if r=255 and g=0 and b=0thisform.shape1.curvature=0elseif r=0 and g=255 and b=0thisform.shape1.curvature=50elseif r=0 and g=0 and b=255thisform.shape1.curvature=99elsethisform.shape1.curvature=1endifendifendifthisform.refresh230305、stfn.scx参考解答:对象command1(偶数字符串按钮)的click事件s=alltrim(thisform.text1.value)n=len(s)js=””for i=1 to nc=substr(s,i,1)if c>="0" and c<="9"d=val(c)if d%2=0js=js+cendifendifendforthisform.text2.value=jsthisform.refresh230306、addcal.scx参考解答:对象command1(添加按钮)的click事件s=thisform.text1.valuen=str(len(s))a=s+space(1)+alltrim(n)thisform.list1.additem(a)thisform.text1.setfocus230307、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.refresh230308、leapyear.scx参考解答:●对象command1(是否闰年按钮)的click事件y=year(thisform.text1.value)if (y%4=0 and y%100!=0) or y%400=0thisform.text2.value="是闰年"elsethisform.text2.value="不是闰年"endifthisform.refresh230309、factor.scx参考解答:对象command1(因子个数按钮)的click事件n=thisform.text1.valuejs=0for i=1 to n-1if n%i=0js=js+1endifendforthisform.text2.value=jsthisform.refresh230310、stat.scx参考解答:对象command1(数字字符个数按钮)的click事件s=alltrim(thisform.text1.value)n=len(s)js=0for i=1 to nc=substr(s,i,1)if c>="0" and c<="9"js=js+1endifendforthisform.text2.value=jsthisform.refresh。