
calculadora en visual basic
Publicado por victor manuel (1 intervención) el 14/09/2015 07:41:00
quisiera ver si alguien me puede ayudar me encargaron que hiciera una calculadora de operaciones basicas en visual basic (suma resta multiplicacion y division) ya la tengo pero solo que me encargaron que en el caso de la suma resta y multiplicacion se pudieran hacer con N numeros por ejemplo 2+3+4+5+6+7 o 3-4-5-67-9 o 3*5*7*
yo solo la tengo y puedo hacer operaciones con dos valores aqui esta el codigo no se como puedo hacerle es la primera vez que llevo esta materia y no tengo ni idea espero alguien me pueda ayudar de antemano gracias.
codigo:
yo solo la tengo y puedo hacer operaciones con dos valores aqui esta el codigo no se como puedo hacerle es la primera vez que llevo esta materia y no tengo ni idea espero alguien me pueda ayudar de antemano gracias.
codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Public Class Form1
Dim cifra1 As Double
Dim cifra2 As Double
Dim resultado As Double
Dim op As Double
Dim punto As Double
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub bt0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt0.Click
TextBox1.Text = TextBox1.Text + "0"
End Sub
Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1.Click
TextBox1.Text = TextBox1.Text + "1"
End Sub
Private Sub bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt2.Click
TextBox1.Text = TextBox1.Text + "2"
End Sub
Private Sub bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt3.Click
TextBox1.Text = TextBox1.Text + "3"
End Sub
Private Sub bt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt4.Click
TextBox1.Text = TextBox1.Text + "4"
End Sub
Private Sub bt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt5.Click
TextBox1.Text = TextBox1.Text + "5"
End Sub
Private Sub bt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt6.Click
TextBox1.Text = TextBox1.Text + "6"
End Sub
Private Sub bt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt7.Click
TextBox1.Text = TextBox1.Text + "7"
End Sub
Private Sub bt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt8.Click
TextBox1.Text = TextBox1.Text + "8"
End Sub
Private Sub bt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt9.Click
TextBox1.Text = TextBox1.Text + "9"
End Sub
Private Sub btpunto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btpunto.Click
TextBox1.Text = TextBox1.Text + "."
punto = 1
If punto = 1 Then
btpunto.Enabled = False
End If
End Sub
Private Sub btmas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmas.Click
op = 1
cifra1 = Val(TextBox1.Text)
TextBox1.Clear()
btpunto.Enabled = True
End Sub
Private Sub btigual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btigual.Click
btpunto.Enabled = True
cifra2 = Val(TextBox1.Text)
If op = 1 Then
resultado = cifra1 + cifra2
TextBox1.Text = resultado
Else
If op = 2 Then
resultado = cifra1 - cifra2
TextBox1.Text = resultado
Else
If op = 3 Then
resultado = cifra1 * cifra2
TextBox1.Text = resultado
Else
If op = 4 Then
resultado = cifra1 / cifra2
TextBox1.Text = resultado
End If
End If
End If
End If
End Sub
Private Sub btmenos_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmenos.Click
op = 2
cifra1 = Val(TextBox1.Text)
TextBox1.Clear()
btpunto.Enabled = True
End Sub
Private Sub btmult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btmult.Click
op = 3
cifra1 = Val(TextBox1.Text)
TextBox1.Clear()
btpunto.Enabled = True
End Sub
Private Sub btdivision_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btdivision.Click
op = 4
cifra1 = Val(TextBox1.Text)
TextBox1.Clear()
btpunto.Enabled = True
End Sub
Private Sub btlimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlimpiar.Click
TextBox1.Clear()
btpunto.Enabled = True
End Sub
End Class
Valora esta pregunta


0