Aquí tienes el Source del Form
Abre un block de notas pega esto guardalo con extensión ".frm"
No Hubique bien los controles y demas ok, lo demas es cosa tuya
A si y leete un Manual de Visual Basic, por si fuera poco. ¡!
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4200
ClientLeft = 60
ClientTop = 375
ClientWidth = 7815
LinkTopic = "Form1"
ScaleHeight = 4200
ScaleWidth = 7815
StartUpPosition = 3 'Windows Default
Begin VB.OptionButton optSi
Caption = "Option1"
Height = 255
Left = 5520
TabIndex = 8
Top = 3600
Width = 1215
End
Begin VB.OptionButton optD2
Caption = "Option1"
Height = 255
Left = 120
TabIndex = 5
Top = 1320
Width = 1335
End
Begin VB.HScrollBar hsbCA
Height = 255
Left = 120
TabIndex = 2
Top = 840
Width = 4095
End
Begin VB.HScrollBar hsbBA
Height = 255
Left = 120
TabIndex = 1
Top = 480
Width = 4095
End
Begin VB.PictureBox pctBox
Height = 855
Left = 1800
ScaleHeight = 795
ScaleWidth = 2715
TabIndex = 0
Top = 1440
Width = 2775
End
Begin VB.Label lblX2
Caption = "Label1"
Height = 375
Left = 5400
TabIndex = 7
Top = 2880
Width = 1455
End
Begin VB.Label lblX1
Caption = "Label1"
Height = 375
Left = 5280
TabIndex = 6
Top = 1680
Width = 1095
End
Begin VB.Label lblCA
Caption = "Label1"
Height = 255
Left = 4800
TabIndex = 4
Top = 1080
Width = 1335
End
Begin VB.Label lblBA
Caption = "Label1"
Height = 255
Left = 4920
TabIndex = 3
Top = 600
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim a, b, c As Double
Dim x1, x2, dis, xr, xi As Double
Private Sub divisiones(nx As Integer, ny As Integer)
Dim i As Integer
Dim x, xinc, y, yinc As Single
pctBox.DrawWidth = 1
xinc = 20 / (nx - 1)
x = -10
For i = 1 To nx
pctBox.Line (x, 0)-(x, -1)
x = x + xinc
Next i
yinc = 10 / (ny - 1)
y = -5
For i = 1 To ny
pctBox.Line (-1, y)-(0, y)
y = y + yinc
Next i
pctBox.DrawWidth = 2
End Sub
Private Sub cmdSalir_Click()
End
End Sub
Private Sub Form_Load()
pctBox.Scale (-10, 5)-(10, -5)
End Sub
Private Sub hsbBA_Change()
a = 1
b = hsbBA.Value / 10#
c = hsbCA.Value / 10#
lblBA.Caption = b
lblCA.Caption = c
dis = b ^ 2 - 4 * a * c
If optD2.Value = True Then 'mantener
pctBox.AutoRedraw = True
Else: 'borrar
pctBox.AutoRedraw = False
pctBox.Cls
End If
If dis > 0 Then
x1 = (-b + Sqr(dis)) / (2 * a)
x2 = (-b - Sqr(dis)) / (2 * a)
lblX1.Caption = Format(x1, "###0.000")
lblX2.Caption = Format(x2, "###0.000")
pctBox.PSet (x1, 0), vbRed
pctBox.PSet (x2, 0), vbRed
ElseIf dis = 0 Then
x1 = -b / (2 * a)
x2 = x1
lblX1.Caption = Format(x1, "###0.000")
lblX2.Caption = ""
pctBox.PSet (x1, 0), vbGreen
Else
xr = -b / (2 * a)
xi = Sqr(-dis) / (2 * a)
lblX1.Caption = Format(xr, "###0.000")
lblX2.Caption = Format(xi, "###0.000")
pctBox.PSet (xr, xi), vbBlue
pctBox.PSet (xr, -xi), vbBlue
End If
If optSi = True Then
Call divisiones(10, 5)
End If
End Sub
Private Sub hsbCA_Change()
a = 1
b = hsbBA.Value / 10#
c = hsbCA.Value / 10#
lblBA.Caption = b
lblCA.Caption = c
dis = b ^ 2 - 4 * a * c
If optD2.Value = True Then 'mantener
pctBox.AutoRedraw = True
Else: 'borrar
pctBox.AutoRedraw = False
pctBox.Cls
End If
If dis > 0 Then
x1 = (-b + Sqr(dis)) / (2 * a)
x2 = (-b - Sqr(dis)) / (2 * a)
lblX1.Caption = Format(x1, "###0.000")
lblX2.Caption = Format(x2, "###0.000")
pctBox.PSet (x1, 0), vbRed
pctBox.PSet (x2, 0), vbRed
ElseIf dis = 0 Then
x1 = -b / (2 * a)
x2 = x1
lblX1.Caption = Format(x1, "###0.000")
lblX2.Caption = ""
pctBox.PSet (x1, 0), vbGreen
Else
xr = -b / (2 * a)
xi = Sqr(-dis) / (2 * a)
lblX1.Caption = Format(xr, "###0.000")
lblX2.Caption = Format(xi, "###0.000")
pctBox.PSet (xr, xi), vbBlue
pctBox.PSet (xr, -xi), vbBlue
End If
If optSi = True Then
Call divisiones(10, 5)
End If
End Sub
Private Sub optD1_Click()
pctBox.AutoRedraw = True
pctBox.Cls
pctBox.DrawWidth = 1
pctBox.Line (-90, 0)-(90, 0), vbBlack
pctBox.Line (0, -45)-(0, 45), vbBlack
pctBox.DrawWidth = 2
End Sub
Private Sub pctBox_Paint()
pctBox.AutoRedraw = True
pctBox.Line (-90, 0)-(90, 0), vbBlack
pctBox.Line (0, -45)-(0, 45), vbBlack
pctBox.DrawWidth = 2
End Sub