网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

VFP6.0做计算器

时间:2024-10-29 19:57:50

计算器大家都很熟悉。俎振裣奇今天我来分享一下我怎么用VFP6做计算器!

效果图:

VFP6.0做计算器

工具/原料

VFP6.0

打开VFP,文件——新建——表单——新建立文件

VFP6.0做计算器

lable1在属性中设置它的caption属性为"前项"

lable2在属性中设置它的caption属性为"后项"

lable3在属性中设置它的caption属性为"结果"

text1、text2、text3不用设置

optiongroup1的生成器:VFP6.0做计算器

command1在属性中设置它的caption属性为“计算”

command2在属性中设置它的caption属性为“退出”

接着像下图摆好:

VFP6.0做计算器

接着双击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

VFP6.0做计算器

command2代码:

thisform.release

VFP6.0做计算器

运行,用最简单的算式测试一下:

VFP6.0做计算器

© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com