I tried anything like in if statement but I dont know what should i type in order to replace NaN with a zero or a message like "empty"
please help me guys im just new to Ms Visual Studio 2010
thanks in advance
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
If txtA.Text = Nothing Then
MessageBox.Show("textbox A value is Missing! please input a value", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
txtA.Focus()
Exit Sub
End If
If txtB.Text = Nothing Then
MessageBox.Show("textbox B value is Missing! please input a value", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
txtB.Focus()
Exit Sub
End If
If txtC.Text = Nothing Then
MessageBox.Show("textbox C value is Missing! please input a value", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
txtC.Focus()
Exit Sub
End If
Dim a, b, c, x1, x2 As Double
a = Val(txtA.Text)
b = Val(txtB.Text)
c = Val(txtC.Text)
x1 = Format(Val(-b + Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a), "#,###.00")
x2 = Format(Val(-b - Math.Sqrt(b ^ 2 - 4 * a * c)) / (2 * a), "#,###.00")
lblOutput2.Text = "{" & x1 & " , " & x2 & "}"
If txtA.Text = Nothing Then
lblOutput2.Text = "no value computed!"
ElseIf txtB.Text = Nothing Then
lblOutput2.Text = "no Value Computed!"
ElseIf txtC.Text = Nothing Then
lblOutput2.Text = "no value Computed!"
ElseIf txtA.Text = 0 Then
MessageBox.Show("Invalid Divisor!, put a valid numeric VALUE!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
lblOutput2.Text = "Invalid"
ElseIf lblOutput2.Text = is Then
lblOutput2.Text = "ERROR!"
End If
End Sub


Reply With Quote
