I have a bunch of formulas in my code. Some are in DGV Cells and some in texboxes. In some before the all the data is processed it shows NaN and I'd prefer it didn't do that.
This formula doesn't do show NaN in the textbox
While this one does NOT show NaN
This formula doesn't do show NaN in the textbox
VB.NET:
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
' For Changes to Valve Area
Dim count = Val(Me.TextBox7.Text) ' Number of valves
Dim vdiam = Val(Me.TextBox1.Text) ' Valve Diameter
Dim varea = vdiam * vdiam * 0.7854 'Valve Area (Diameter^2 * Pi / 4)
For Each r As DataGridViewRow In Me.DGV1.Rows
'Populates CFM -Sq.In Column using formula = CFM / Valve Area
r.Cells(4).Value = CDbl(r.Cells(2).Value) / varea
'Valve Area calculation
Me.TextBox9.Text = CStr(Val(varea * count))
Next
End Sub
While this one does NOT show NaN
VB.NET:
Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
'Average Port Area Textbox - Populates Average Velocity [Column 9 of DGV] With Formulated Values
Dim Roof = Val(TextBox4.Text)
Dim Floor = Val(TextBox5.Text)
Dim CLine = Val(TextBox4.Text) + Val(TextBox5.Text) / 2
Dim Pvol = Val(TextBox6.Text)
For Each r As DataGridViewRow In Me.DGV1.Rows
'Average Port Velocity Formula = ( Flow_CFM * 2.4 ) / Average_CSA
r.Cells(9).Value = (CDbl(r.Cells(2).Value) * 2.4) / Val(Me.TextBox8.Text)
'Average Port Area = Port_Volume_CC / (Port_CenterLine_Length * 16.387)
Me.TextBox8.Text = CStr(Pvol / (CLine * 16.387))
Next
End Sub