VFP表单中如何使两个文本框中的数据经过计算显示在第三个文本框中

2025-05-14 03:19:46
推荐回答(1个)
回答1:

简单方法:建一个按钮, 在 click 事件中写如下代码:
thisform.text3.value = thisform.text1.value + thisform.text2.value
**点出这个按钮时 完成计算

复杂一点:
**text1.interActivateChange 事件中写:
thisform.text3.value = thisform.text1.value + thisform.text2.value
**text2.interActivateChange 事件中也写:
thisform.text3.value = thisform.text1.value + thisform.text2.value
**动态更新计算结果

再复杂一点
建立一个thisform.calcTxt3 方法,在这个方法中写:
thisform.text3.value = thisform.text1.value + thisform.text2.value
**text1.interActivateChange 事件中写:
thisform.calcTxt3 ()
**text2.interActivateChange 事件中也写:
thisform.calcTxt3 ()
**动态更新计算结果,程序更规范

**三种方法都要求,text 文本框要初始化为 数值型,不然会报错。