I'd create a Calculation Command Button and put your code in there.
Private Sub CommandButton1_Click()
Dim TempCalc As Double
Debug.Print "TextBox1: ", TextBox1.Value
Debug.Print "TextBox2: ", TextBox2.Value
Debug.Print "TextBox3: ", TextBox3.Value
Debug.Print "TextBox4: ", TextBox4.Value
Dim SqrtVal As Double
SqrtVal = Sqr(CLng(TextBox1.Value) * 1 - CLng(TextBox1.Value))
Debug.Print "SqrtVal: ", SqrtVal
Dim DivVal As Double
DivVal = (CLng(TextBox1.Value) * CLng(TextBox2.Value))
Debug.Print "DivVal: ", DivVal
Dim PowerVal As Double
PowerVal = (SqrtVal / DivVal) ^ 2
Debug.Print "PowerVal: ", PowerVal
TempCalc = CLng(TextBox3.Value) * 16 * PowerVal
Debug.Print "TempCalc: ", TempCalc
TextBox5.Value = TempCalc
End Sub
But, as you can see, the results are zero.
Results:
TextBox1: 4
TextBox2: 5
TextBox3: 3
TextBox4: 20
SqrtVal: 0
DivVal: 20
PowerVal: 0
TempCalc: 0
Unless my maths is off, this will give you a zero value:
CLng(TextBox1.Value) * 1 - CLng(TextBox1.Value)
You can't bracket it like this:
CLng(TextBox1.Value) * (1 - CLng(TextBox1.Value))
because the multiplication would give you a minus number and Sqr won't like that.
Bookmarks