elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  errores ejecucion. grafica de la solucion de la ecuacion de segundo grado.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: errores ejecucion. grafica de la solucion de la ecuacion de segundo grado.  (Leído 3,276 veces)
@ron

Desconectado Desconectado

Mensajes: 75


Homer Tux!!


Ver Perfil
errores ejecucion. grafica de la solucion de la ecuacion de segundo grado.
« en: 17 Junio 2009, 01:52 am »

este es el libro de donde saque el problema de la solucion grafica a ecuaciones de segundo grado pagina 89.

http://www.tecnun.es/asignaturas/Informat1/ayudainf/aprendainf/VisualBasic6/vbasic60.pdf

lo que pasa es que no me sale, cambie los nombres de los controles a como originalmente me salen (command1, picture1,etc,) pero aun asi sigo teniendo problemas, entoncs queria saber si el problema era el mal cambio de nombres que hize yo o no. Tambien cabe mencionar que me marca un error en una, creo q es variable llamada xinc. Ps aversi me pueden ayudar con ese problema.

*La imagen del programa viene dentro del libro del *.pdf



Citar
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



saludos y gracias por su tiempo...!


En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: errores ejecucion. grafica de la solucion de la ecuacion de segundo grado.
« Respuesta #1 en: 17 Junio 2009, 04:05 am »

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. ¡!

Código
  1. VERSION 5.00
  2. Begin VB.Form Form1
  3.   Caption         =   "Form1"
  4.   ClientHeight    =   4200
  5.   ClientLeft      =   60
  6.   ClientTop       =   375
  7.   ClientWidth     =   7815
  8.   LinkTopic       =   "Form1"
  9.   ScaleHeight     =   4200
  10.   ScaleWidth      =   7815
  11.   StartUpPosition =   3  'Windows Default
  12.   Begin VB.OptionButton optSi
  13.      Caption         =   "Option1"
  14.      Height          =   255
  15.      Left            =   5520
  16.      TabIndex        =   8
  17.      Top             =   3600
  18.      Width           =   1215
  19.   End
  20.   Begin VB.OptionButton optD2
  21.      Caption         =   "Option1"
  22.      Height          =   255
  23.      Left            =   120
  24.      TabIndex        =   5
  25.      Top             =   1320
  26.      Width           =   1335
  27.   End
  28.   Begin VB.HScrollBar hsbCA
  29.      Height          =   255
  30.      Left            =   120
  31.      TabIndex        =   2
  32.      Top             =   840
  33.      Width           =   4095
  34.   End
  35.   Begin VB.HScrollBar hsbBA
  36.      Height          =   255
  37.      Left            =   120
  38.      TabIndex        =   1
  39.      Top             =   480
  40.      Width           =   4095
  41.   End
  42.   Begin VB.PictureBox pctBox
  43.      Height          =   855
  44.      Left            =   1800
  45.      ScaleHeight     =   795
  46.      ScaleWidth      =   2715
  47.      TabIndex        =   0
  48.      Top             =   1440
  49.      Width           =   2775
  50.   End
  51.   Begin VB.Label lblX2
  52.      Caption         =   "Label1"
  53.      Height          =   375
  54.      Left            =   5400
  55.      TabIndex        =   7
  56.      Top             =   2880
  57.      Width           =   1455
  58.   End
  59.   Begin VB.Label lblX1
  60.      Caption         =   "Label1"
  61.      Height          =   375
  62.      Left            =   5280
  63.      TabIndex        =   6
  64.      Top             =   1680
  65.      Width           =   1095
  66.   End
  67.   Begin VB.Label lblCA
  68.      Caption         =   "Label1"
  69.      Height          =   255
  70.      Left            =   4800
  71.      TabIndex        =   4
  72.      Top             =   1080
  73.      Width           =   1335
  74.   End
  75.   Begin VB.Label lblBA
  76.      Caption         =   "Label1"
  77.      Height          =   255
  78.      Left            =   4920
  79.      TabIndex        =   3
  80.      Top             =   600
  81.      Width           =   1095
  82.   End
  83. End
  84. Attribute VB_Name = "Form1"
  85. Attribute VB_GlobalNameSpace = False
  86. Attribute VB_Creatable = False
  87. Attribute VB_PredeclaredId = True
  88. Attribute VB_Exposed = False
  89. Option Explicit
  90.  
  91. Dim a, b, c As Double
  92. Dim x1, x2, dis, xr, xi As Double
  93.  
  94. Private Sub divisiones(nx As Integer, ny As Integer)
  95. Dim i As Integer
  96. Dim x, xinc, y, yinc As Single
  97. pctBox.DrawWidth = 1
  98. xinc = 20 / (nx - 1)
  99. x = -10
  100. For i = 1 To nx
  101. pctBox.Line (x, 0)-(x, -1)
  102. x = x + xinc
  103. Next i
  104. yinc = 10 / (ny - 1)
  105. y = -5
  106. For i = 1 To ny
  107. pctBox.Line (-1, y)-(0, y)
  108. y = y + yinc
  109. Next i
  110. pctBox.DrawWidth = 2
  111. End Sub
  112.  
  113. Private Sub cmdSalir_Click()
  114. End
  115. End Sub
  116. Private Sub Form_Load()
  117. pctBox.Scale (-10, 5)-(10, -5)
  118. End Sub
  119.  
  120. Private Sub hsbBA_Change()
  121. a = 1
  122. b = hsbBA.Value / 10#
  123. c = hsbCA.Value / 10#
  124. lblBA.Caption = b
  125. lblCA.Caption = c
  126. dis = b ^ 2 - 4 * a * c
  127. If optD2.Value = True Then 'mantener
  128. pctBox.AutoRedraw = True
  129. Else: 'borrar
  130. pctBox.AutoRedraw = False
  131. pctBox.Cls
  132. End If
  133. If dis > 0 Then
  134. x1 = (-b + Sqr(dis)) / (2 * a)
  135. x2 = (-b - Sqr(dis)) / (2 * a)
  136. lblX1.Caption = Format(x1, "###0.000")
  137. lblX2.Caption = Format(x2, "###0.000")
  138. pctBox.PSet (x1, 0), vbRed
  139. pctBox.PSet (x2, 0), vbRed
  140. ElseIf dis = 0 Then
  141. x1 = -b / (2 * a)
  142. x2 = x1
  143. lblX1.Caption = Format(x1, "###0.000")
  144. lblX2.Caption = ""
  145. pctBox.PSet (x1, 0), vbGreen
  146. Else
  147. xr = -b / (2 * a)
  148. xi = Sqr(-dis) / (2 * a)
  149. lblX1.Caption = Format(xr, "###0.000")
  150. lblX2.Caption = Format(xi, "###0.000")
  151. pctBox.PSet (xr, xi), vbBlue
  152. pctBox.PSet (xr, -xi), vbBlue
  153. End If
  154. If optSi = True Then
  155. Call divisiones(10, 5)
  156. End If
  157. End Sub
  158.  
  159. Private Sub hsbCA_Change()
  160. a = 1
  161. b = hsbBA.Value / 10#
  162. c = hsbCA.Value / 10#
  163. lblBA.Caption = b
  164. lblCA.Caption = c
  165. dis = b ^ 2 - 4 * a * c
  166. If optD2.Value = True Then 'mantener
  167. pctBox.AutoRedraw = True
  168. Else: 'borrar
  169. pctBox.AutoRedraw = False
  170. pctBox.Cls
  171. End If
  172. If dis > 0 Then
  173. x1 = (-b + Sqr(dis)) / (2 * a)
  174. x2 = (-b - Sqr(dis)) / (2 * a)
  175. lblX1.Caption = Format(x1, "###0.000")
  176. lblX2.Caption = Format(x2, "###0.000")
  177. pctBox.PSet (x1, 0), vbRed
  178. pctBox.PSet (x2, 0), vbRed
  179. ElseIf dis = 0 Then
  180. x1 = -b / (2 * a)
  181. x2 = x1
  182. lblX1.Caption = Format(x1, "###0.000")
  183. lblX2.Caption = ""
  184. pctBox.PSet (x1, 0), vbGreen
  185. Else
  186. xr = -b / (2 * a)
  187. xi = Sqr(-dis) / (2 * a)
  188. lblX1.Caption = Format(xr, "###0.000")
  189. lblX2.Caption = Format(xi, "###0.000")
  190. pctBox.PSet (xr, xi), vbBlue
  191. pctBox.PSet (xr, -xi), vbBlue
  192. End If
  193. If optSi = True Then
  194. Call divisiones(10, 5)
  195. End If
  196. End Sub
  197.  
  198. Private Sub optD1_Click()
  199. pctBox.AutoRedraw = True
  200. pctBox.Cls
  201. pctBox.DrawWidth = 1
  202. pctBox.Line (-90, 0)-(90, 0), vbBlack
  203. pctBox.Line (0, -45)-(0, 45), vbBlack
  204. pctBox.DrawWidth = 2
  205. End Sub
  206.  
  207. Private Sub pctBox_Paint()
  208. pctBox.AutoRedraw = True
  209. pctBox.Line (-90, 0)-(90, 0), vbBlack
  210. pctBox.Line (0, -45)-(0, 45), vbBlack
  211. pctBox.DrawWidth = 2
  212. End Sub
  213.  


En línea

The Dark Shadow is my passion.
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
duda ecuación de segundo grado c++
Programación C/C++
rub'n 8 9,416 Último mensaje 14 Mayo 2010, 02:31 am
por do-while
Ayuda, matemáticas,ecuación de primer grado. « 1 2 »
Dudas Generales
anonimo12121 10 9,105 Último mensaje 3 Febrero 2011, 15:15 pm
por anonimo12121
Ecuación de segundo grado.
Dudas Generales
anonimo12121 6 5,626 Último mensaje 4 Abril 2011, 23:21 pm
por anonimo12121
Ecuación de segundo grado [Complejos]
Programación C/C++
programator11 6 4,625 Último mensaje 6 Agosto 2014, 16:11 pm
por Xandrete
[Haskell] Soluciones reales de una ecuación de segundo grado
Ejercicios
seryioo 0 4,222 Último mensaje 18 Julio 2018, 10:45 am
por seryioo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines