VFP题目及答案

  • 格式:pdf
  • 大小:133.80 KB
  • 文档页数:14

VFP题⽬及答案

1.在两个⽂本框中分别输⼊⽤户名和密码,点击“注册”按钮,出现三种情况:

a)若⾄少⼀个⽂本框为空,者提⽰“⽤户名或密不能为空!”

b)若输⼊的⽤户名的已经在后台的“⽤户”表中存在,则提⽰“此⽤户名已被占⽤,请重

新输⼊!”c)排除上述两种情况,则出现“注册成功”信息,并把该新注册的⽤户名及密码写⼊后台

的“⽤户”表中2.输⼊⽤户名和密码,点击“登录”按钮,可能出现的三种情况:

a)该⽤户已在⽤户表中,⽽且密码也正确,则出现“您已成功登录本系统”的信息;

b)若⽤户名已存在于后台的“⽤户”表中,则显⽰“密码错误”的信息

c)若⽤户名不在⽤“户表”中,则显⽰“您尚未注册”的信息

3.点击“退出”按钮,退出程序

注册(command1)clickif allt(thisform.text1.value)=="" or allt(thisform.text2.value)==""

messagebox("⽤户名或密码不能为空!",17,"提⽰")

else

sele ⽤户

locate for ⽤户名=allt(thisform.text1.value)

if found()

messagebox("此⽤户名已被占⽤,请重新输⼊!",49,"提⽰")

else

append blank

replace ⽤户名with alltrim(thisform.text1.value)

replace 密码with alltrim(thisform.text2.value)

messagebox("注册成功",65,"恭喜!")

thisform.text1.value=""

thisform.text2.value=""

endif

endif

登⼊(command2)clickif allt(thisform.text1.value)=="" or allt(thisform.text2.value)==""

messagebox("⽤户名或密码不能为空!",17,"提⽰")

else

select ⽤户

locate for allt(⽤户名)==allt(thisform.text1.value)if found()

if allt(密码)==allt(thisform.text2.value)

messagebox("您已成功登录本系统!",65,"恭喜")

else

messagebox("密码错误!",49,"提⽰")

endif

else

messagebox("您尚未注册!",49,"提⽰")

endif

endif

选择左边组合框中的课程号,右侧列表中显⽰该课程的全部成绩。Combo1 interactivechange

select 课程

locate for 课程号=this.value

thisform.refresh

在左上⾓⽂本框中输⼊学号,点击“查找”按钮,右侧显⽰该学⽣的相关信息。

若输⼊学号为空,则出现“学号不能为空”的提⽰;

若所输⼊的学号不在学⽣表中,则显⽰“查⽆此⼈!”

查找(command1)Clicksele 学⽣

if allt(thisform.text1.value)==""

messagebox("学号不能为空")

thisform.text1.setfocus

else

locate for 学号=allt(thisform.text1.value)

if not found()

messagebox("查⽆此⼈!",17,"出错啦!")

thisform.text1.value=""

thisform.text1.setfocus

endif

endif

thisform.refresh

点击“转换”按钮,完成摄⽒到华⽒、华⽒到摄⽒、摄⽒到摄⽒、华⽒到华⽒的转换。

转换(command1)Clickif allt(thisform.text1.value)==""return

else

if val(thisform.text1.value)=0

return

else

if thisform.combo1.value=thisform.combo2.value

thisform.text2.value=thisform.text1.value

else

if thisform.combo1.value="摄⽒"

thisform.text2.value=9/5*val(thisform.text1.value)+32

else

thisform.text2.value=((val(thisform.text1.value))-32)*5/9

endif

endif

endif

endif

thisform.refresh

1.点击“出题”按钮,由程序随机产⽣两个两位数的正整数,分别填写在左侧的两个⽂本框中;

2.⽤户输⼊上述两个数相加的结果,点击“答题”按钮,出现以下两种可能的情况:

a)若⽤户计算正确,则给出“答对了,真棒!”的提⽰

b)若⽤户给出的答案错误,则给出“不对啊,再仔细想想!”的提⽰。

3.点击“退出”按钮,退出程序

出题(command1)clickthisform.text1.value=int(rand()*90)+10

thisform.text2.value=int(rand()*90)+10

thisform.text3.value=""

thisform.refresh

答题(command2)clicka=val(thisform.text3.value)

b=thisform.text1.value

c=thisform.text2.value

if a=b+c

messagebox("答对了,真棒!",65,"congratulations")

else

messagebox("不对啊,再仔细想想!",17,"出错啦!")endif

1.⽤户选择组合框中的学号,右侧⽂本框中显⽰相应的姓名;

2.点击“确定”按钮,出现两个可能的情况::

c)若⽤户勾选了⾄少⼀个运动项⽬,则把学号、姓名及所报项⽬写⼊后台的“报名表”,

且在界⾯的表格控件中显⽰报名结果d)若⽤户没有勾选任何运动项⽬,则不写表。

3.点击“清空报名表”按钮,则清空后台“报名表”中的所有数据,并在界⾯的表格控件中反映出来。

4.点击“退出”按钮,退出程序。

确定(command)n=0

if thisform.combo1.value==""

return

endif

select 报名表

if thisform.check1.value=.t.

n=1

endif

if thisform.check2.value=.t.

n=1

endif

if thisform.check3.value=.t.

n=1

endif

if n=1

append blank

replace 学号with thisform.combo1.value,姓名with thisform.txt姓名.value

if thisform.check1.value=.t.

replace 项⽬1 with thisform.check1.caption

endif

if thisform.check2.value=.t.

replace 项⽬2 with thisform.check2.caption

endif

if thisform.check3.value=.t.

replace 项⽬3 with thisform.check3.caption

endifendif

thisform.refresh

清空报名表select 报名表

zap

thisform.refresh

combo interactivechange

thisform.check1.value=.f.

thisform.check2.value=.f.

thisform.check3.value=.f.

thisform.refresh

1.点击“查找”按钮,可能出现的三种情况:

a)若学号⽂本框为空,则出现“学号不能为空”的提⽰

b)若在成绩表中找不到输⼊的学号,则出现“没有找到该学⽣的成绩”的提⽰

c)若输⼊的学号在成绩表中找到,则右侧的表格控件显⽰该学⽣的所有成绩,并在下

⽅的⽂本框中显⽰该学⽣所有课程的平均成绩。2.点击“退出”按钮,退出程序。

查找if allt(thisform.text1.value)==""

messagebox("学号不能为空!")

return

endif

sele 成绩

locate for allt(学号)=allt(thisform.text1.value)

if found()

sele * from 成绩where allt(学号)=allt(thisform.text1.value) into cursor 个⼈成绩

thisform.grid1.recordsourcetype=1

thisform.grid1.recordsource="个⼈成绩"

thisform.grid1.visible=.t.

sele avg(成绩) as 平均成绩from 个⼈成绩into cursor pjcj

sele pjcj

thisform.text2.value=平均成绩

else

messagebox("没有找到该学⽣的成绩!")

thisform.grid1.visible=.f.