Calcular la suma de dos numeros Visual Basic 6.0
| Control | Propiedad | Valor |
| Label1 | (Nombre) | LblNumero1 |
| Caption | Ingrese el Primer Número : | |
| Label2 | (Nombre) | LblNumero2 |
| Caption | Ingrese el Segundo Número : | |
| Label3 | (Nombre) | LblResultado |
| Caption | El Resultado es : | |
| TextBox1 | (Nombre) | TxtNumero1 |
| Text | (Vacio) | |
| TextBox2 | (Nombre) | TxtNumero2 |
| Caption | (Vacio) | |
| TextBox3 | (Nombre) | TxtResultado |
| Caption | (Vacio) | |
| Command1 | (Nombre) | CmdCalcular |
| Caption | Calcular | |
| Command2 | (Nombre) | CmdLimpiar |
| Caption | Limpiar | |
| Command3 | (Nombre) | CmdCerrar |
| Caption | Cerrar |
CODIGO FUENTE
Private Sub CmdCalcular_Click()
TxtResultado.Text = Val(TxtNumero1.Text) + Val(TxtNumero2.Text)
End Sub
Private Sub CmdCerrar_Click()
Unload Me
End
End Sub
Private Sub CmdLimpiar_Click()
TxtNumero1.Text = ""
TxtNumero2.Text = ""
TxtResultado.Text = ""
TxtNumero1.SetFocus
End Sub
UTILIZANDO VARIABLES
Private Sub CmdCalcular_Click()
Dim numero1, numero2, resultado As Integer
numero1 = Val(TxtNumero1.Text)
numero2 = Val(TxtNumero2.Text)
resultado = Val(TxtNumero1.Text) + Val(TxtNumero2.Text)
TxtResultado.Text = resultado
End Sub
Calcular el area del triangulo Visual Basic 6.0
CALCULAR EL AREA DEL TRIANGULO
PRIMER PASO EL DISEÑO
PROPIEDADES
| Control | Propiedad | Valor |
| Label1 | (Nombre) | LblBase |
| Caption | Ingrese la base : | |
| Label2 | (Nombre) | LblAltura |
| Caption | Ingrese la altura : | |
| Label3 | (Nombre) | LblArea |
| Caption | El area del triangulo es : | |
| TextBox1 | (Nombre) | TxtBase |
| Text | (Vacio) | |
| TextBox2 | (Nombre) | TxtAltura |
| Caption | (Vacio) | |
| TextBox3 | (Nombre) | TxtArea |
| Caption | (Vacio) | |
| Command1 | (Nombre) | CmdCalcular |
| Caption | Calcular | |
| Command2 | (Nombre) | CmdLimpiar |
| Caption | Limpiar | |
| Command3 | (Nombre) | CmdCerrar |
| Caption | Cerrar |
CODIGO FUENTE
Private Sub CmdCalcular_Click()
TxtArea.Text = (Val(TxtBase.Text) * Val(TxtAltura.Text)) / 2
End Sub
Private Sub CmdCerrar_Click()
Unload Me
End
End Sub
Private Sub CmdLimpiar_Click()
TxtBase.Text = ""
TxtAltura.Text = ""
TxtArea.Text = ""
TxtBase.SetFocus
End Sub
UTILIZANDO VARIABLES
El codigo seria :
Private Sub CmdCalcular_Click()
Dim area, base, altura As Double
base = Val(TxtBase.Text)
altura = Val(TxtAltura.Text)
area = (base * altura) / 2
TxtArea.Text = area
End Sub




No hay comentarios:
Publicar un comentario