Mar Sep 28, 2010 6:36 pm
- Código:
' Gambas class file
PUBLIC SUB Form_Open()
reiniciar
var.zoom = 0
END
PUBLIC SUB ToolButton1_Click()
DIM discriminante AS Single
IF ValueBoxB.value = NULL THEN
Message.Error("Debe de dar valores a B")
GOTO fincalcular
ENDIF
IF ValueBoxA.Value = 0 THEN
Message.Error("Debe de dar valores a A")
GOTO fincalcular
END IF
discriminante = ValueBoxB.Value * ValueBoxB.Value - 4 * ValueBoxA.Value * ValueBoxC.value
IF discriminante < 0 THEN
Labelsolucion.text = "Soluciones de X (con numeros complejos):"
Labelsolucion.visible = TRUE
i1.Visible = TRUE
i2.Visible = TRUE
labely.Visible = TRUE
ValueBox1.visible = TRUE
ValueBox2.Visible = TRUE
ValueBox3.Visible = TRUE
ValueBox4.visible = TRUE
mas1.Visible = TRUE
mas2.Visible = TRUE
ValueBox1.value = - ValueBoxB.value / (2 * ValueBoxA.value)
ValueBox2.value = ValueBox1.Value
ValueBox3.value = Sqr(- discriminante) / (2 * ValueBoxA.Value)
ValueBox4.value = - ValueBox3.Value
dibujarecuacion
ToolButton1.visible = FALSE
GOTO fincalcular
ELSE
IF discriminante = 0 THEN
Labelsolucion.visible = TRUE
ValueBox1.visible = TRUE
ValueBox1.value = - ValueBoxB.Value / (2 * ValueBoxA.value)
ValueBox2.Visible = FALSE
labely.visible = FALSE
dibujarecuacion
ToolButton1.visible = FALSE
GOTO fincalcular
ELSE
Labelsolucion.visible = TRUE
ValueBox1.visible = TRUE
ValueBox2.Visible = TRUE
labely.visible = TRUE
ValueBox1.Value = (- ValueBoxB.Value + Sqr(discriminante)) / (2 * ValueBoxA.Value)
ValueBox2.Value = (- ValueBoxB.Value - Sqr(discriminante)) / (2 * ValueBoxA.Value)
dibujarecuacion
ToolButton1.visible = FALSE
GOTO fincalcular
ENDIF
ENDIF
fincalcular:
'final del calculo
END
SUB reiniciar()
Labelsolucion.visible = FALSE
i1.Visible = FALSE
i2.Visible = FALSE
labely.Visible = FALSE
ValueBox1.visible = FALSE
ValueBox2.Visible = FALSE
ValueBox3.Visible = FALSE
ValueBox4.visible = FALSE
mas1.Visible = FALSE
mas2.Visible = FALSE
ValueBoxA.value = 0
ValueBoxB.value = 0
ValueBoxC.value = 0
END
PUBLIC SUB Button2_Click()
QUIT
END
PUBLIC SUB Button1_Click()
ToolButton1.visible = TRUE
reiniciar()
END
SUB dibujarecuacion()
dibuja.dibuja_parabola(0)
END
PUBLIC SUB zoommas_Click()
var.zoom = var.zoom + 0.1
dibuja.dibuja_parabola(var.zoom)
END
PUBLIC SUB zoommenos_Click()
var.zoom = var.zoom - 0.1
dibuja.dibuja_parabola(var.zoom)
END
*Este es parecido al VB pero para GNU