How to write the code for return value of textbox divided by another Textbox
- Thread is marked as Resolved.
Welcome to Ozgrid Forum. An example workbook is much better than an image..
An entry in a TextBox is by default a String so you cannot use them in calculations even if they look like a number. You need to convert the String to a Numeric value as you have using Val(TextBox4.value). All TextBoxes for the calculation must be changed you can use Val, cInt, cDbl. For a list of conversion functions see:-
Take a look to the following lines:
If you want to add more restrictions use the Url
Dim fs As Double
If (Not VarType(.TextBox1.Value) = vbString And Not .TextBox1.Value = 0) And _
(Not VarType(.TextBox2.Value) = vbString And Not .TextBox1.Value = 0) Then
fs = .TextBox1.Value / .TextBox2.Value
Don’t have an account yet? Register yourself now and be a part of our community!