我有3个旧表单字段,名为text1,text2和text3。我的示例代码是:
Option Explicit
Public a as integer
Public b as integer
Public c as integer
Sub TextA()
If ActiveDocument.FormFields("text1").Result = "" Then
MsgBox "You must specify a number. If none, enter a zero."
End If
a = ActiveDocument.FormFields("text1").Result
End Sub
Sub TextB()
If ActiveDocument.FormFields("text2").Result = "" Then
MsgBox "You must specify a number. If none, enter a zero."
End If
b = ActiveDocument.FormFields("text2").Result
End Sub
Sub CalculateC()
c = a + b
End Sub
现在text1和text2分别在退出时运行第一个两个subs(在其属性菜单中设置)...我希望text3自动显示c。我以为我可以使用表单字段属性"计算"或者运行sub(或者在条目上运行?) - 或者两者兼而有之,但是不能让它工作。我有什么选择?
答案 0 :(得分:0)
我进行了一些研究并发现了计算在字段中的工作原理...我在text1&中检查了“退出时计算”。 text2,并选择“Calculation”作为text3上的类型,表达式为“= text1 + text2”,不需要VBA。然后我可以有一个宏来记录text2 + text2在text2中退出时运行的结果,如果我需要捕获该变量供以后使用。