Consulta también:
- Ayudenme a crear un calculadora en vb
- Descargar calculadora para pc - Programas - Calculadoras
- Como crear un grupo en messenger - Guide
- Crear un bat para ejecutar un comando en cmd - Guide
- Crear icono a partir de imagen - Guide
- Crear iso - Guide
1 respuesta
claro
usa este codigo
1.
Public Class Form1
2.
Function buscar(ByVal txtval As String, ByVal car As Char) As Boolean
3.
Dim b As Integer
4.
For b = 1 To txtval.Length
5.
If Convert.ToChar(Mid(txtval, b, 1)) = car Then
6.
Return False
7.
End If
8.
Next
9.
Return True
10.
End Function
11.
Dim val1, val2 As Double
12.
Dim banR, ban, ban_br As Integer
13.
Dim oper As String
14.
Private Sub txt0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt0.Click
15.
If banR = 0 Then
16.
r.Text &= "0"
17.
Else
18.
r.Text = "0"
19.
End If
20.
End Sub
21.
22.
Private Sub txt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt1.Click
23.
If banR = 0 Then
24.
r.Text &= "1"
25.
Else
26.
r.Text = "1"
27.
End If
28.
End Sub
29.
30.
Private Sub txt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt2.Click
31.
If banR = 0 Then
32.
r.Text &= "2"
33.
Else
34.
r.Text = "2"
35.
End If
36.
End Sub
37.
38.
Private Sub txt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt3.Click
39.
If banR = 0 Then
40.
r.Text &= "3"
41.
Else
42.
r.Text = "3"
43.
End If
44.
End Sub
45.
46.
Private Sub txt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt4.Click
47.
If banR = 0 Then
48.
r.Text &= "4"
49.
Else
50.
r.Text = "4"
51.
End If
52.
End Sub
53.
54.
Private Sub txt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt5.Click
55.
If banR = 0 Then
56.
r.Text &= "5"
57.
Else
58.
r.Text = "5"
59.
End If
60.
End Sub
61.
62.
Private Sub txt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt6.Click
63.
If banR = 0 Then
64.
r.Text &= "6"
65.
Else
66.
r.Text = "6"
67.
End If
68.
End Sub
69.
70.
Private Sub txt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt7.Click
71.
If banR = 0 Then
72.
r.Text &= "7"
73.
Else
74.
r.Text = "7"
75.
End If
76.
End Sub
77.
78.
Private Sub txt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt8.Click
79.
If banR = 0 Then
80.
r.Text &= "8"
81.
Else
82.
r.Text = "8"
83.
End If
84.
End Sub
85.
86.
Private Sub txt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt9.Click
87.
If banR = 0 Then
88.
r.Text &= "9"
89.
Else
90.
r.Text = "9"
91.
End If
92.
End Sub
93.
94.
Private Sub txtce_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtce.Click
95.
oper = ""
96.
val2 = 0
97.
r.Text = ""
98.
banR = 0
99.
ban_br = 0
100.
r.Focus()
101.
End Sub
102.
103.
Private Sub txtc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtc.Click
104.
banR = 0
105.
ban = 0
106.
ban_br = 0
107.
oper = ""
108.
val1 = 0
109.
val2 = 0
110.
r.Text = ""
111.
r.Focus()
112.
End Sub
113.
114.
Private Sub txtigual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtigual.Click
115.
val2 = Val(r.Text)
116.
Select Case oper
117.
Case "+"
118.
val1 += val2
119.
Case "-"
120.
val1 -= val2
121.
Case "*"
122.
val1 *= val2
123.
Case "/"
124.
val1 /= val2
125.
End Select
126.
r.Text = val1
127.
banR = 1
128.
ban = 1
129.
ban_br = 1
130.
End Sub
131.
132.
Private Sub txtadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtadd.Click
133.
If ban = 0 Then
134.
val1 = Val(r.Text)
135.
oper = "+"
136.
r.Text = ""
137.
r.Focus()
138.
ban = 1
139.
Else
140.
val2 = Val(r.Text)
141.
If ban_br = 1 Then 'si ya presiono el boton de =
142.
ban_br = 0
143.
Else
144.
Select Case oper
145.
Case "+"
146.
val1 += val2
147.
Case "-"
148.
Case "*"
149.
Case "/"
150.
End Select
151.
End If
152.
oper = "+"
153.
r.Text = val1
154.
banR = 1
155.
End If
156.
End Sub
157.
158.
Private Sub txtsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsub.Click
159.
If ban = 0 Then
160.
val1 = Val(r.Text)
161.
oper = "-"
162.
r.Text = ""
163.
r.Focus()
164.
ban = 1
165.
Else
166.
val2 = Val(r.Text)
167.
If ban_br = 1 Then 'si ya presiono el boton de =
168.
ban_br = 0
169.
Else
170.
Select Case oper
171.
Case "+"
172.
val1 += val2
173.
Case "-"
174.
Case "*"
175.
Case "/"
176.
End Select
177.
End If
178.
oper = "-"
179.
r.Text = val1
180.
banR = 1
181.
End If
182.
End Sub
183.
184.
Private Sub txtmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtmul.Click
185.
If ban = 0 Then
186.
val1 = Val(r.Text)
187.
oper = "*"
188.
r.Text = ""
189.
r.Focus()
190.
ban = 1
191.
Else
192.
val2 = Val(r.Text)
193.
If ban_br = 1 Then 'si ya presiono el boton de =
194.
ban_br = 0
195.
Else
196.
Select Case oper
197.
Case "+"
198.
val1 += val2
199.
Case "-"
200.
Case "*"
201.
Case "/"
202.
End Select
203.
End If
204.
oper = "*"
205.
r.Text = val1
206.
banR = 1
207.
End If
208.
End Sub
209.
210.
Private Sub txtdiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtdiv.Click
211.
If ban = 0 Then
212.
val1 = Val(r.Text)
213.
oper = "/"
214.
r.Text = ""
215.
r.Focus()
216.
ban = 1
217.
Else
218.
val2 = Val(r.Text)
219.
If ban_br = 1 Then 'si ya presiono el boton de =
220.
ban_br = 0
221.
Else
222.
Select Case oper
223.
Case "+"
224.
val1 += val2
225.
Case "-"
226.
Case "*"
227.
Case "/"
228.
End Select
229.
End If
230.
oper = "/"
231.
r.Text = val1
232.
banR = 1
233.
End If
234.
End Sub
235.
236.
Private Sub txtpunto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpunto.Click
237.
If buscar(r.Text, ".") = True Then
238.
r.Text &= "."
239.
End If
240.
End Sub
241.
End Class
usa este codigo
1.
Public Class Form1
2.
Function buscar(ByVal txtval As String, ByVal car As Char) As Boolean
3.
Dim b As Integer
4.
For b = 1 To txtval.Length
5.
If Convert.ToChar(Mid(txtval, b, 1)) = car Then
6.
Return False
7.
End If
8.
Next
9.
Return True
10.
End Function
11.
Dim val1, val2 As Double
12.
Dim banR, ban, ban_br As Integer
13.
Dim oper As String
14.
Private Sub txt0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt0.Click
15.
If banR = 0 Then
16.
r.Text &= "0"
17.
Else
18.
r.Text = "0"
19.
End If
20.
End Sub
21.
22.
Private Sub txt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt1.Click
23.
If banR = 0 Then
24.
r.Text &= "1"
25.
Else
26.
r.Text = "1"
27.
End If
28.
End Sub
29.
30.
Private Sub txt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt2.Click
31.
If banR = 0 Then
32.
r.Text &= "2"
33.
Else
34.
r.Text = "2"
35.
End If
36.
End Sub
37.
38.
Private Sub txt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt3.Click
39.
If banR = 0 Then
40.
r.Text &= "3"
41.
Else
42.
r.Text = "3"
43.
End If
44.
End Sub
45.
46.
Private Sub txt4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt4.Click
47.
If banR = 0 Then
48.
r.Text &= "4"
49.
Else
50.
r.Text = "4"
51.
End If
52.
End Sub
53.
54.
Private Sub txt5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt5.Click
55.
If banR = 0 Then
56.
r.Text &= "5"
57.
Else
58.
r.Text = "5"
59.
End If
60.
End Sub
61.
62.
Private Sub txt6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt6.Click
63.
If banR = 0 Then
64.
r.Text &= "6"
65.
Else
66.
r.Text = "6"
67.
End If
68.
End Sub
69.
70.
Private Sub txt7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt7.Click
71.
If banR = 0 Then
72.
r.Text &= "7"
73.
Else
74.
r.Text = "7"
75.
End If
76.
End Sub
77.
78.
Private Sub txt8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt8.Click
79.
If banR = 0 Then
80.
r.Text &= "8"
81.
Else
82.
r.Text = "8"
83.
End If
84.
End Sub
85.
86.
Private Sub txt9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt9.Click
87.
If banR = 0 Then
88.
r.Text &= "9"
89.
Else
90.
r.Text = "9"
91.
End If
92.
End Sub
93.
94.
Private Sub txtce_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtce.Click
95.
oper = ""
96.
val2 = 0
97.
r.Text = ""
98.
banR = 0
99.
ban_br = 0
100.
r.Focus()
101.
End Sub
102.
103.
Private Sub txtc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtc.Click
104.
banR = 0
105.
ban = 0
106.
ban_br = 0
107.
oper = ""
108.
val1 = 0
109.
val2 = 0
110.
r.Text = ""
111.
r.Focus()
112.
End Sub
113.
114.
Private Sub txtigual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtigual.Click
115.
val2 = Val(r.Text)
116.
Select Case oper
117.
Case "+"
118.
val1 += val2
119.
Case "-"
120.
val1 -= val2
121.
Case "*"
122.
val1 *= val2
123.
Case "/"
124.
val1 /= val2
125.
End Select
126.
r.Text = val1
127.
banR = 1
128.
ban = 1
129.
ban_br = 1
130.
End Sub
131.
132.
Private Sub txtadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtadd.Click
133.
If ban = 0 Then
134.
val1 = Val(r.Text)
135.
oper = "+"
136.
r.Text = ""
137.
r.Focus()
138.
ban = 1
139.
Else
140.
val2 = Val(r.Text)
141.
If ban_br = 1 Then 'si ya presiono el boton de =
142.
ban_br = 0
143.
Else
144.
Select Case oper
145.
Case "+"
146.
val1 += val2
147.
Case "-"
148.
Case "*"
149.
Case "/"
150.
End Select
151.
End If
152.
oper = "+"
153.
r.Text = val1
154.
banR = 1
155.
End If
156.
End Sub
157.
158.
Private Sub txtsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsub.Click
159.
If ban = 0 Then
160.
val1 = Val(r.Text)
161.
oper = "-"
162.
r.Text = ""
163.
r.Focus()
164.
ban = 1
165.
Else
166.
val2 = Val(r.Text)
167.
If ban_br = 1 Then 'si ya presiono el boton de =
168.
ban_br = 0
169.
Else
170.
Select Case oper
171.
Case "+"
172.
val1 += val2
173.
Case "-"
174.
Case "*"
175.
Case "/"
176.
End Select
177.
End If
178.
oper = "-"
179.
r.Text = val1
180.
banR = 1
181.
End If
182.
End Sub
183.
184.
Private Sub txtmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtmul.Click
185.
If ban = 0 Then
186.
val1 = Val(r.Text)
187.
oper = "*"
188.
r.Text = ""
189.
r.Focus()
190.
ban = 1
191.
Else
192.
val2 = Val(r.Text)
193.
If ban_br = 1 Then 'si ya presiono el boton de =
194.
ban_br = 0
195.
Else
196.
Select Case oper
197.
Case "+"
198.
val1 += val2
199.
Case "-"
200.
Case "*"
201.
Case "/"
202.
End Select
203.
End If
204.
oper = "*"
205.
r.Text = val1
206.
banR = 1
207.
End If
208.
End Sub
209.
210.
Private Sub txtdiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtdiv.Click
211.
If ban = 0 Then
212.
val1 = Val(r.Text)
213.
oper = "/"
214.
r.Text = ""
215.
r.Focus()
216.
ban = 1
217.
Else
218.
val2 = Val(r.Text)
219.
If ban_br = 1 Then 'si ya presiono el boton de =
220.
ban_br = 0
221.
Else
222.
Select Case oper
223.
Case "+"
224.
val1 += val2
225.
Case "-"
226.
Case "*"
227.
Case "/"
228.
End Select
229.
End If
230.
oper = "/"
231.
r.Text = val1
232.
banR = 1
233.
End If
234.
End Sub
235.
236.
Private Sub txtpunto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpunto.Click
237.
If buscar(r.Text, ".") = True Then
238.
r.Text &= "."
239.
End If
240.
End Sub
241.
End Class