subline html模板:用vfp编写的计算器代码

来源:百度文库 编辑:高校问答 时间:2024/04/29 03:14:25
拜托各位,帮帮忙!不胜感激!

1)【提示】 操作步骤:
1)【提示】 操作步骤:
??第一步:向表单添加文本框和命令组控件,分别设置命令按钮的Caption属性,在对命令按钮"="的Caption
??属性设置时,不能在其属性窗口中直接输入半角的"=",否则提示语法错误。可以输入全角"="
??或在表单FROM1的Init事件中,输入如下代码完成:
??for i=1 to 10
??this.commandgroup1.buttons(i).caption=alltrim(str(i))
??endfor
??this.commandgroup1.buttons(11).caption="*"
??this.commandgroup1.buttons(12).caption="+"
??this.commandgroup1.buttons(13).caption="-"
??this.commandgroup1.buttons(14).caption="="
??this.commandgroup1.buttons(15).caption="C"
??
??第二步:在表单FORM1的Init事件中定义全局变量T,并赋初值空串
??PUBLIC T=''
??第三步:编写命令组的Click事件代码,完成接收输入的表达式:
??do case
??case this.value=1
??t=t+"1"
??thisform.text1.value=t
??case this.value=2
??t=t+"2"
??thisform.text1.value=t
??case this.value=3
??t=t+"3"
??thisform.text1.value=t
??case this.value=4
??t=t+"4"
??thisform.text1.value=t
??case this.value=5
??t=t+"5"
??thisform.text1.value=t
??case this.value=6
??t=t+"6"
??thisform.text1.value=t
??case this.value=7
??t=t+"7"
??thisform.text1.value=t
??case this.value=8
??t=t+"8"
??thisform.text1.value=t
??case this.value=9
??t=t+"9"
??thisform.text1.value=t
??case this.value=10
??t=t+"0"
??thisform.text1.value=t
??case this.value=11
??t=t+"*"
??thisform.text1.value=t
??case this.value=12
??t=t+'+'
??thisform.text1.value=t
??case this.value=13
??t=t+'-'
??thisform.text1.value=t
??case this.value=14
??thisform.text1.value=alltrim(str(&t,20,6)) && 宏替换T将得到数值表达式计算结果,20与6可以自己根据需要确定
??case this.value=15
??t=''
??thisform.text1.value=t
??endcase
??thisform.refresh
??
??第四步:当输入的表达式错误时,将引发命令组的Error事件,编写命令组的Error事件代码:
??thisform.text1.value="运算式错误"