VBScript Example

A

andy

Greetings,

I know VB, and a little VBA, but no VBScript. Would
someone give me a working snippet of VBScript code to put
behind the following example of a form. Also can someone
please recommend a good VBScripting book?

An outlook form which has 3 textfields. 2 fields (txt1,
and txt2) into which a user would input a number, and the
3rd field (txtSum) sums the two input fields. I would like
the sum field to update on change of either of the 2 input
fields.

A simplistic way to do it in VB is as follows:

Public varSum As Integer

Private Sub txt1_Change()
SumValues
End Sub

Private Sub txt2_Change()
SumValues
End Sub

Private Sub SumValues()
varSum = Val(txt1.text) + Val(txt2.text)
txtSum = varSum
End Sub

Thank you in advance
God bless you
 
Top