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

"/calculadora - TXT": Form1

This document describes a simple calculator application with the following functionality: - It contains text boxes to enter two numbers and a label to display the result. - Buttons to perform addition, subtraction, multiplication and division calculations on the two numbers. - A button to clear the text boxes and label. - A button to close the application. - A button to save the calculations to a text file on the desktop. - It only allows numeric input in the text boxes and handles divide by zero errors.

Uploaded by

Carlos Alvarado
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)
28 views2 pages

"/calculadora - TXT": Form1

This document describes a simple calculator application with the following functionality: - It contains text boxes to enter two numbers and a label to display the result. - Buttons to perform addition, subtraction, multiplication and division calculations on the two numbers. - A button to clear the text boxes and label. - A button to close the application. - A button to save the calculations to a text file on the desktop. - It only allows numeric input in the text boxes and handles divide by zero errors.

Uploaded by

Carlos Alvarado
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

Imports System.

IO
Public Class Form1
Dim directorio = My.Computer.FileSystem.SpecialDirectories.Desktop &
"\calculadora.txt"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
Label1.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles


Button4.Click

If Val(TextBox2.Text) <> 0 Then


Label1.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
ElseIf Val(TextBox2.Text) = 0 Then
Label1.Text = "ERROR!!!!!"
End If

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles


Button5.Click
TextBox1.Text = ""
TextBox2.Text = ""
Label1.Text = ""

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles


Button6.Click
Me.Close()
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles


Button7.Click
My.Computer.FileSystem.WriteAllText(directorio, vbCrLf & "Primer numero: " &
TextBox1.Text & vbTab & "Segundo numero: " & TextBox2.Text & vbTab & "Resultado: " &
Label1.Text & vbCrLf, True)

End Sub

Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
MessageBox.Show("Solo se permiten numeros")
End If
End Sub

Private Sub TextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox2.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
MessageBox.Show("Solo se permiten numeros")
End If
End Sub
End Class

You might also like