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

Calculadora

This document contains the code for a basic calculator application. It includes code for number buttons, arithmetic operation buttons, and a reset button. When number buttons are clicked, the corresponding number is appended to the display textbox. When an operation button is clicked, the current value and operation are stored and the display is cleared. The equal button performs the calculation and displays the result. There is also code to change the color of a label on a timer to demonstrate additional functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Calculadora

This document contains the code for a basic calculator application. It includes code for number buttons, arithmetic operation buttons, and a reset button. When number buttons are clicked, the corresponding number is appended to the display textbox. When an operation button is clicked, the current value and operation are stored and the display is cleared. The equal button performs the calculation and displays the result. There is also code to change the color of a label on a timer to demonstrate additional functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Calculadora

Codificación:
Public Class Form1

Dim OPERACION As String


Dim VALORresultado As Nullable(Of Double) = Nothing
Dim valor2 As Nullable(Of Double) = Nothing
Dim precionador As Boolean
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
evaluarestriccionesparaconcatenar()
TextBox1.Text &= "1"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
evaluarestriccionesparaconcatenar()
TextBox1.Text &= "2"
End Sub

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


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "3"
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
evaluarestriccionesparaconcatenar()
TextBox1.Text &= "4"
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
evaluarestriccionesparaconcatenar()
TextBox1.Text &= "5"
End Sub

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


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "6"
End Sub

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


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "7"
End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "8"

End Sub

Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "9"

End Sub

Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click


evaluarestriccionesparaconcatenar()
TextBox1.Text &= "0"

End Sub

Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click


evaluarestriccionesparaconcatenar()
If InStr(TextBox1.Text, ".", CompareMethod.Text) = 0 Then
TextBox1.Text &= "."
End If
End Sub

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click


evaluayhazoperacion()
OPERACION = ""

End Sub

Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click


TextBox1.Text = "0"
valor2 = Nothing
VALORresultado = Nothing
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
evaluayhazoperacion()
OPERACION = "+"
End Sub

Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click


evaluayhazoperacion()
OPERACION = "-"
End Sub

Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click


evaluayhazoperacion()
OPERACION = "*"
End Sub

Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click


evaluayhazoperacion()
OPERACION = "/"
End Sub
Public Sub evaluayhazoperacion()
precionador = True
valor2 = Val(TextBox1.Text)
If VALORresultado IsNot Nothing Then
Select Case OPERACION
Case "+"
VALORresultado = VALORresultado + valor2
Case "-"
VALORresultado -= valor2
Case "*"
VALORresultado *= valor2
Case "/"
VALORresultado /= valor2
End Select
TextBox1.Text = VALORresultado
Else
VALORresultado = valor2
End If
End Sub
Public Sub evaluarestriccionesparaconcatenar()
If precionador = True Then
TextBox1.Text = ""
precionador = False
ElseIf TextBox1.Text = "0" Then
TextBox1.Text = ""
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer
c = c + 1
If c = 1 Then
Label1.ForeColor = Color.YellowGreen
ElseIf c = 2 Then
Label1.ForeColor = Color.Purple
ElseIf c = 3 Then
Label1.ForeColor = Color.Brown
ElseIf c = 4 Then
Label1.ForeColor = Color.Blue
ElseIf c = 5 Then
Label1.ForeColor = Color.Azure
ElseIf c = 6 Then
Label1.ForeColor = Color.Red
Else : c = 4
c = 0
End If
End Sub
End Class

You might also like