Ejercicios de Visual Basic 2
Realizar un programa para obtener el área de un circulo
1. Insertamos los objetos con sus respectivos nombres
OBJETO
|
NOMBRE
|
CAPTION
|
|
Form
|
frmPrincipal
|
AREA DEL CIRCULO
|
|
Label
|
lblArea
|
AREA
|
|
Label
|
lblRadio
|
RADIO
|
|
TextBox
|
txtArea
|
||
TextBox
|
txtRadio
|
||
CommandButton
|
btnCalcular
|
CALCULAR
|
|
CommandButton
|
btnSalir
|
SALIR
|
EN EL PROGRAMA DEBE VISUALIZARSE ASI:
2. Colocamos el siguiente codigo
Option Explicit
Private Sub btnCalcular_Click()
Const pi = 3.141516
Dim radio As Integer
Dim area As Single
radio = InputBox("Ingrese radio", "dato del usuario")
txtRadio.Text = radio
txtArea.Text = pi * radio ^ 2
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