miércoles, 25 de febrero de 2009

Funcion sqr ( ) Raiz cuadrada.

la ecuación cuadrática

x1 = ( -b + sqr((b*b)-4*a*c)) / (2*a)

x2 = ( -b + sqr((b*b)-4*a*c)) / (2*a)

En este caso primero debes declarar tres variables para poder ejecutar las operaciones.

Ejemplo con dim

dim a As Double
dim b As Double
dim c As Double
dim x1 As Double
dim x2 As double
a = text1.text
b = text2.text
c = text3.text
x1 = ( -b + sqr((b*b)-4*a*c)) / (2*a)
x2 = ( -b + sqr((b*b)-4*a*c)) / (2*a)

text4.text = x1
text5.text = x2

Observa que las operaciones se realizan por separado x1 y x2 pero para mostrar el resultado lo haces utilizando la herramienta textbox.

Es como si fuera la instrucción imprimir resultado.

Ejemplo con val ( )

a = val (text1.text)
b = val (text2.text)
c = val (text3.text)
text4.text = (-b + sqr( (b*b)-4*a*c)) / (2*a)
text5.text = (-b - sqr( (b*b)-4*a*c)) / (2*a)