lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I have userform which has 3 text boxes. I want to add 2 numbers and put the result in the 3 box when I click on + command button. Everything is working fine but if I only entered one number in first box and left the other box empty and then press + button, I get error message. How can I improve the code below. Thank you so much.
I have userform which has 3 text boxes. I want to add 2 numbers and put the result in the 3 box when I click on + command button. Everything is working fine but if I only entered one number in first box and left the other box empty and then press + button, I get error message. How can I improve the code below. Thank you so much.
Code:
Private Sub myadd_Click()
result.Value = CInt(first.Value) + CInt(second.Value)
End Sub