I have created an Excel form which has five text boxes. These TextBoxes accept any numerical value. Once the five numbers have been entered there is a sixth Textbox that shows the sum of these values. The sum of these values should always be 100%. Here is my code:
Private Sub TextBox1_Change()
Dim Value As Single
Value = Val(TextBox1.Value) + Val(TextBox2.Value) + Val(TextBox3.Value) + Val(TextBox4.Value) + Val(TextBox5.Value)
TextBox6.Value = Value
End Sub
I have the same code for all Text-box change events. Unfortunately this is not working. When I enter 10, 20, 30, 40 as my input, instead of displaying 100% it shows 10203040 as the result.
What am I doing wrong?
Valueis a single,TextBox1.ValuetoTextBox5.Valuewould automatically be converted to numeric. TheValis not strictly necessary.