VFP6.0做计算器
计算器大家都很熟悉。俎振裣奇今天我来分享一下我怎么用VFP6做计算器!
效果图:
工具/原料
VFP6.0
打开VFP,文件——新建——表单——新建立文件
lable1在属性中设置它的caption属性为"前项"
lable2在属性中设置它的caption属性为"后项"
lable3在属性中设置它的caption属性为"结果"
text1、text2、text3不用设置
optiongroup1的生成器:
command2在属性中设置它的caption属性为“退出”
接着像下图摆好:
接着双击command1,输入click代码:
a=val(alltrim(thisform.text1.value)) &&去除前后空格,并将字符型数据转换为数值型数据
b=val(alltrim(thisform.text2.value)) &&由于文本框默认的数据类型是字符型,所以要转换
if thisform.optiongroup1.value=1
thisform.text3.value=a+b
endif
if thisform.optiongroup1.value=2
thisform.text3.value=a-b
endif
if thisform.optiongroup1.value=3
thisform.text3.value=a*b
endif
if thisform.optiongroup1.value=4
thisform.text3.value=a/b
endif
command2代码:
thisform.release
运行,用最简单的算式测试一下: