Calcular El Area Del Triangulo Visual Basic 6
Calcular El Area Del Triangulo Visual Basic 6
Calcular El Area Del Triangulo Visual Basic 6
PROPIEDADES
Control
Propiedad
Valor
Label1
(Nombre)
LblBase
Caption
Ingrese la base :
(Nombre)
LblAltura
Caption
Ingrese la altura :
(Nombre)
LblArea
Caption
(Nombre)
TxtBase
Text
(Vacio)
(Nombre)
TxtAltura
Caption
(Vacio)
(Nombre)
TxtArea
Caption
(Vacio)
(Nombre)
CmdCalcular
Caption
Calcular
(Nombre)
CmdLimpiar
Caption
Limpiar
(Nombre)
CmdCerrar
Caption
Cerrar
Label2
Label3
TextBox1
TextBox2
TextBox3
Command1
Command2
Command3
CODIGO FUENTE
. PROGRAMA DE PRACTICA
Calcular el area del cuadrado,circulo y triangulo donde el usuario elija por medio de option
button y cada boton le diga que tenga que hacer para la operacion. El resultado es claro que debe ser
en una caja de texto.
1. PLANEACION
*Calcular el rea del circulo, rectngulo y triangulo por medio de option button.
*Mostrar el resultado en una caja de texto.
*Necesitamos 3 cajas de texto, 2 label, 1 frame, 3 optiond button y 3 comandbutton donde
calcularemos
1.1 LISTA DE CHEQUEO:
*Declarar variables
*Darles Valor
*Operar
*Mostrar resultado
2. INTERFAZ GRAFICA
Text3.Visible = True
Label1.Caption = "ingrese lado"
TRIANGULO.Visible = False
CIRCULO.Value = False
Label2.Visible = False
Text2.Visible = False
End Sub
como podemos ver ocultamos los dos comandbutton de calcular que no utilizaremos y el label 2 y
text2.
en el option 2 escribimos el siguiente codigo
Private Sub Option2_Click()
Option2.Value = False
TRIANGULO.Visible = True
Label1.Visible = True
Label2.Visible = True
Text1.Visible = True
Text2.Visible = True
Text3.Visible = True
Label1.Caption = "INGRESE BASE"
Label2.Caption = "INGRESE ALTURA"
CUADRADO.Visible = False
CIRCULO.Value = False
End Sub
En este solo ocultamos los dos comand de calcular.
el otro option button tendras que hacer el codigo. en los comand de calcular haremos la formula de
cada area como por ejemplo.
Private Sub CUADRADO_Click()
A = Text1.Text
RES = A * A
Text3.Text = RES
End Sub
Private Sub TRIANGULO_Click()
B = Text1.Text
A = Text2.Text
RES = B * A / 2
Text3.Text = RES
End Sub
Private Sub CIRCULO_Click()
RADIO = Text1.Text AC = PI * (RADIO * RADIO)
Text3.Text = AC
End Sub
y en general :
Const PI As Double = 3.1416
Dim RADIO As Double
Dim AC As Double
Dim A As Double
Dim B As Double
Dim RES As Double
End Sub