miércoles, 1 de febrero de 2017

Ejercicios de Visual Basic 1

Realizar un programa para obtener el área de un triangulo


1. Insertamos los objetos con sus respectivos nombre


OBJETO
NOMBRE
CAPTION
Form
frmPrincipal
AREA DEL TRIANGULO
Label
lblArea
AREA
Label
lblBase
BASE
Label
lblAltura
ALTURA
TextBox
txtArea

TextBox
txtAltura

TextBox
txtBase

CommandButton
btnCalcular
CALCULAR
CommandButton
btnSalir
SALIR

EN EL PROGRAMA VISUALIZAMOS ASI





2. Colocamos el siguiente codigo 


Private Sub Form_Load()
txtBase = ""
txtAltura = ""
txtArea = ""
'txtArea.Enabled = False
'txtArea.Visible = False
End Sub

Private Sub btnCalcular_Click()
Dim base As Integer
Dim altura As Integer
Dim area As Single
base = InputBox("ingrese valor de la base", "dato del Usuario")
altura = InputBox("ingrese valor de la altura", "dato del Usuario")
txtBase = Val(base)
txtAltura = Val(altura)
txtArea = (base * altura / 2)

base = Val(txtBase)
altura = Val(txtAltura)
txtArea = (base * altura / 2)
'txtArea.Visible = True

End Sub

Private Sub btnSalir_Click()
End
End Sub

EN EL PROGRAMA VISUALIZAMOS ASI


UNA VEZ TERMINADO PONEMOS EJECUTAR


Y  de este modo hemos terminado con este ejercicio














No hay comentarios:

Publicar un comentario