THIS MI CLASS
Public Class Formula
Private a As Integer
Private b As Integer
Private c As Integer
Public Sub seta(ByVal x As Integer)
a = x
End Sub
Public Sub setb(ByVal y As Integer)
b = y
End Sub
Public Sub setc(ByVal z As Integer)
c = z
End Sub
Public Function formucuadramas() As Integer
Return -b + System.Math.Sqrt(b ^ 2 - (-4 * (a * c))) / 2 * (a)
End Function
Public Function formucuadramenos() As Integer
Return -b - System.Math.Sqrt(b ^ 2 - (-4 * (a * c))) / 2 * (a)
End Function
End Class
THIS MI INTERFACE
Module Module1
Sub Main()
Dim nuevo As New Formula
nuevo.seta(1)
nuevo.setb(2)
nuevo.setc(-8)
Dim respuestax1 As Integer = nuevo.formucuadramas()
Console.WriteLine("X =")
Console.WriteLine(respuestax1)
Dim respuestax2 As Integer = nuevo.formucuadramenos()
Console.WriteLine("X =")
Console.WriteLine(respuestax2)
End Sub
End Module
The problem is if I put a negative number like -8 in the variable the exception is activate...just work with positive number...how can I use negative number in this program??