0% found this document useful (0 votes)
26 views2 pages

Form1 Object Eventargs: 'Dim Aux As Single

This Visual Basic code defines the form and controls for a simple area calculator application. It includes event handler subroutines for the calculate, clear, and exit buttons that get user input for base and height values, call a function to calculate the area, and display or clear the results. Validation is included to ensure positive numeric values are entered.

Uploaded by

JOSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Form1 Object Eventargs: 'Dim Aux As Single

This Visual Basic code defines the form and controls for a simple area calculator application. It includes event handler subroutines for the calculate, clear, and exit buttons that get user input for base and height values, call a function to calculate the area, and display or clear the results. Validation is included to ensure positive numeric values are entered.

Uploaded by

JOSE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles


MyBase.Load

End Sub

Private Sub btnSalir_Click(sender As System.Object, e As System.EventArgs)


Handles btnSalir.Click
Close()

End Sub

Private Sub btnCalcular_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnCalcular.Click
'Dim AUX As Single

Dim B As Single
Dim H As Single
Dim S As Single
Do
Try
B = InputBox("coloque el Valor de la BASE o CERO (0) para salir",
"Cálculo de Superficies")
If B <= 0 Then
MsgBox("Valor no valido")

End If
Catch ex As Exception
MsgBox("coloque un número positivo o CERO (0) para salir", ,
"Disculpe ....")
B = -1
End Try
Loop Until B > 0
'If B = 0 Then

'Exit Sub
' Else
txtBase.Text = B
Do
Try
H = InputBox("coloque el Valor de la ALTURA o CERO (0) para salir",
"Cálculo de Superficies")
If H <= 0 Then
MsgBox("El valor altura no es valido")

End If
Catch ex As Exception
MsgBox("coloque un número positivo o CERO (0) para salir", ,
"Disculpe ....")
H = -1
End Try
Loop Until H > 0
'End If
'If H = 0 Then
'txtBase.Text = ""
'Exit Sub
'Else
txtAltura.Text = H
S = CalcularSuperficie(B, H)
'MsgBox("el valor de la superficie es " & S, , "Calculo de Superficie")
txtSuperficie.Text = S
'End If
btnLimpiar.Enabled = True
btnCalcular.Enabled = False

End Sub
Private Function CalcularSuperficie(ByVal b1 As Single, ByVal h1 As Single) As
Single
CalcularSuperficie = b1 * h1 / 2
'Return CalcularSuperficie

End Function

Private Sub btnLimpiar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnLimpiar.Click
txtBase.Text = ""
txtAltura.Text = ""
txtSuperficie.Text = ""
btnLimpiar.Enabled = False
btnCalcular.Enabled = True
End Sub

Private Sub txtBase_TextChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles txtBase.TextChanged

End Sub
End Class

You might also like