文档详情

VFP实例小程序—猜页码小游戏.doc

发布:2018-07-02约1.58千字共3页下载文档
文本预览下载声明
VFP实例小程序图文教程——猜页码小游戏所需要运用的知识:表单基本知识textlabelcommand二、IF语句 格式:If 条件语句1Else语句2endif随机函数Rand()为0到1之间的随机小数,保留二位。如你要获得一个3位数的随机整数变量,则可设a=int(rand()*1000)猜页码小游戏的VFP表单界面外观设计猜页码小游戏的VFP表单编程设计表单中各个控件名称在上面全部都标注出来了。设计各个控件Label4在属性中设定label4的caption为“猜页码小游戏”,并设置一下字体大小,颜色等。尽量美观一点(2)label1在属性中设定label1的caption为空(3)label3在属性中设定label3的caption为“总页码数为:”(4)label2在属性中设定label2的caption为“结果显示区”(5)text1在属性中设定text1的value为“=str(int(rand()*1000),8)”,并且设置它为隐藏属性(6)text2在属性中设定text2的value为“=str(int(rand()*10+2),8)”,并且设置它为隐藏属性(7)text3在属性中设定text2的value为空(8)command1在属性中设定command1的caption为“再来一盘”对它的click过程编程为:a=rand()a1=a*1000a2=a1/3+2a11=int(a1)a21=int(a2)thisform.text1.value=str(a11,8)thisform.text2.value=str(a21,8)mand4.caption=答案提示thisform.text3.value=请重新猜thisform.label1.caption=thisform.text1.value(9)command2在属性中设定command2的caption为“开始游戏”对它的click过程编程为:thisform.label1.caption=thisform.text1.value(10)command3在属性中设定command3的caption为“猜一猜”对它的click过程编程为:m0=val(thisform.text2.value)r=val(thisform.text3.value)if rm0 if r=m0 thisform.label2.caption=你真聪明,猜对了 thisform.label2.fontsize=25 thisform.label2.forecolor=rgb(255,0,255) else thisform.label2.caption=太小了 endifelse if r=m0 thisform.label2.caption=你真聪明,猜对了 thisform.label2.fontsize=25 thisform.label2.forecolor=rgb(255,0,255) else thisform.label2.caption=太大了 endifendif(11)command4在属性中设定command4的caption为“提示答案”对它的click过程编程为:mand4.caption=thisform.text2.value游戏玩游戏介绍:先点“开始游戏”然后根据提示的总页码数来猜页码,并将页码输入到文本框中,然后点击“猜一猜”按纽。可以猜多次,猜对之后,会提示你“猜对了”,你所猜的次数越少就越说明你聪明。如果猜不出来,可以点点“答案提示”按纽。如果不想猜这盘,可以点击“重新再来”按纽。
显示全部
相似文档