表单
1.设计标准化模拟考试表单。 (1)表单Form1的Init事件:
Thisform.Optiongroup1.Value=0 (2)Optiongroup1的Click事件
IF This.Value=2
MessageBox(\答对了,真棒!\评判结果\) Else
MessageBox(\答错了,再试!\评判结果\ ENDIF
2.编制一个表单完成表文件\学生.dbf (1)命令按钮Command1的Click事件
GO TOP
Thisform.Command1.Enabled=.F. Thisform.Command2.Enabled=.F. Thisform.Command3.Enabled=.T. Thisform.Command4.Enabled=.T. Thisform.Refresh (2) Command2的Click事件
SKIP -1
IF BOF()
Thisform.Command1.Enabled=.F. Thisform.Command2.Enabled=.F. ELSE
Thisform.Command3.Enabled=.T. Thisform.Command2.Enabled=.T. ENDIF
Thisform.Refresh (3)Command3的Click事件
SKIP
IF EOF()
Thisform.Command3.Enabled=.F. Thisform.Command4.Enabled=.F. ELSE
Thisform.Command1.Enabled=.T. Thisform.Command2.Enabled=.T. ENDIF
Thisform.Refresh (3)Command4 的Click事件
GO BOTTOM
Thisform.Command3.Enabled=.F. Thisform.Command4.Enabled=.F. Thisform.Command1.Enabled=.T. Thisform.Command2.Enabled=.T. Thisform.Refresh
3、编制一个表单完成学生成绩查询显示功能 Combl rowsoursetype 6, rowsourse 学生。姓名 (1)From1的Init事件 SET TALK OFF SELECT 学生 GO top
thisform.combo1.SelectOnEntry= .T. thisform.command1.Default= .T. thisform.combo1.Value=学生.姓名 (2)Command1的Click事件 SELECT 学生
LOCATE FOR ALLTRIM(学号)=ALLTRIM(THISFORM.COMBO1.DISPLAYVALUE) IF FOUND()
SELECT 成绩
AVERAGE 成绩 TO PJCJ FOR 学号=学生.学号 THISFORM.TEXT1.Value=PJCJ
MASSAGE(\输入的姓名不存在!\错误信息\
ELSE ENDIF
THISFORM.COMBO1.SetFocus THISFORM.Refresh
(3)Command2的Click事件 SET TALK ON Thisform.Release
4、编一页面转换表单,要求表单上有一个包含3页的页框,每页依次一幅图画、一张表格、一个列表框。 (1)Form1的Init事件
Thisform.P=0 &&P是用户自定义的属性 (2)Timer1的Timer事件
Thisform.Pageframe1.Page1. Enabled=.F. Thisform.Pageframe1.Page2. Enabled=.F. Thisform.Pageframe1.Page3. Enabled=.F. Thisform.P=Thisform.P+1
IF Thisform.P>Thisform.Pageframe1.Pagecount Thisform.P=1 ENDIF
Thisform.Pageframe1.Pages(Thisform.P).Enabled=.T. Thisform.Pageframe1.Activepage=Thisform.P Thisform.Refresh
5.编制手工日历表单。
(1) 表单FORM1的INIT事件 Thisform.Text1.Value=DATE( ) Thisform.Spinner1.Setfocus (2)微调Spinner1的UpClick事件
Thisform.Text1.Value=Thisform.Text1.Value+1 Thisform.Refresh
(3)微调Spinner1的DownClick事件
Thisform .Text1.Value=Thisform.Text1.Value-1 Thisform . Refresh
6.编制表文件完成自动只读浏览显示功能(表单内容将以2秒为间隔自动刷新) 表单FROM1的INIT事件
Thisform.Setall(“Readonly”,.T.”Textbox”) Thisform.Setall (“Readonly”,.T.,”Editbox”) Thisform Setall (“Readonly ”,.T.,”Checkbox”) 计时器TIMER1的timer事件 Skip IF EOF()
Go TOP ENDIF
Thisform.Refresh
7.设计一个表单,使表单中的信息行显示系统当前时间,并使该信息行在表单内左右缓慢平移。界面如图4-23和图4-24所示。要求:现实时间信息的字体大小为20号。信息先向右移动,且每0.1秒钟移动一个像素点。
(1) 表单Form1的Iint事件 This.caption=”信息移动态平行移动” Thisform.timer1.interval=100
(2)计时器TIMER1的TIMER事件 Thisform..label1.caption=TIME() IF Thisform .Label1.Left<=0 Thisform.D=.T. Endif
If thisform.label1.left>=thisform.width-thisform.label1.width thisform.D=.F. Endif
If thisform.D=.T.
Thisform.label1.left=thisform.label1.left+1 Else
Thisform.label1.left=thisform.label1.left-1 Endif
8.利用计时器空间设计一个模拟拍球动作的表单。具体界面如图4-25和4-26所示。球的起始位置在表单的顶行中部,表单执行后,秋自上而下落下并且球体逐渐变大,当球到达表单底部时自动弹回,并且球体又逐渐回缩变小,当球到达顶部时再次自动下落,如此往复弹跳,仿佛有人用手拍打球,知道关闭表单。 (1)
表单Form1的Init事件
Thisform.shape1.width=40 Thisform.shape1.height=40 Thisform.shape1.top=0 Thisform. t=1
Thisform.timer1.interval=100 (2).计时器Timer1的Timer事件 If thisform.shape1.top<=0 Thisform.T=1 Endif
If thisform.shape1.top>= Thisform . Height- Thisform.shape1.height Thisform.T=0 Endif
If thisform.T=1
Thisform.shape1.top= Thisform.shape1.top+1 Thisform.shape1.width= Thisform.shape1.width+1 Thisform.shape1.height= Thisform.shape1.height+1 Else
Thisform.shape1.top= Thisform.shape1.top-1 Thisform.shape1.width= Thisform.shape1.width-1 Thisform.shape1.height= Thisform.shape1.height-1 Endif
Thisform.refresh
9.设计一个3表关联查询表单 FORM1的INIT的事件
Thisform.setall(“Readonly”,.T.,”Grid”) Thisform.setall(“Allowaddnew”,.F.,”Grid”) Thisform.setall(“Deletemark”,.F.,”Grid”
10.设计一个统计车票总金额的表单。“计算总额”命令按钮 设置“计算总额”Default为.T. Text1 ReadOnly为.T. Command1的Click事件: S=0
IF Thisform.Check1.Value=1
S=S+580
ENDIF
IF Thisform.Check2.Value=1
S=S+50 ENDIF
IF Thisform.Check3.Value=1
S=S+280 ENDIF
Thisform.Text1.Value=S Thisform.Refresh
Command2的Click事件: Thisform.Release
11.计数器计数显示功能。初始显示为“00:00:00”。“计数”、“停止” 时钟设置interval 1000 表单-新建属性--添加S,H,M (1) Form
thisform.timer1.Enabled=.F. thisform.S=0 thisform.H=0 thisform.M=0
thisform.text1.value=\(2) command1
thisform.timer1.Enabled=.T. thisform.S=0 THISFORM.H=0 thisform.M=0
thisform.text1.Value=\THISFORM.Refresh (3) command2
thisform.timer1.Enabled=.F. (4) timer
thisform.S=thisform.S+1 IF thisform.S=60
thisform.S=0
THISFORM.M=thisform.M+1 IF thisform.M=60 THISFORM.M=0
THISFORM.H=THISFORM.H+1 ENDIF
ENDIF
HH=IIF(thisform.H>9,STR(thisform.H,2),\ MM=IIF(thisform.M>9,STR(thisform.M,2),\ SS=IIF(thisform.S>9,STR(thisform.S,2),\ thisform.text1.Value=HH+\THISFORM.Refresh