Val para tomar valores numericos de un text box
Publicado por Axel (2 intervenciones) el 15/09/2015 03:43:39
Soy novato en VB6 y me topé con este problema a la hora de hacer un proyecto de calculadora simple.
No logro que la variable numero2 tome los valores que aparecen en el Text.Box. Qué puede ser? Agradezco mucho su ayuda.
No logro que la variable numero2 tome los valores que aparecen en el Text.Box. Qué puede ser? Agradezco mucho su ayuda.
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
Dim numero1 As Integer
Dim numero2 As Integer
Dim operacion As String
Dim resultado As Integer
Private Sub cmd0_Click()
Text1.Text = Text1.Text & "0"
End Sub
Private Sub cmd1_Click()
Text1.Text = Text1.Text & "1"
End Sub
Private Sub cmd2_Click()
Text1.Text = Text1.Text & "2"
End Sub
Private Sub cmd3_Click()
Text1.Text = Text1.Text & "3"
End Sub
Private Sub cmd4_Click()
Text1.Text = Text1.Text & "4"
End Sub
Private Sub cmd5_Click()
Text1.Text = Text1.Text & "5"
End Sub
Private Sub cmd6_Click()
Text1.Text = Text1.Text & "6"
End Sub
Private Sub cmd7_Click()
Text1.Text = Text1.Text & "7"
End Sub
Private Sub cmd8_Click()
Text1.Text = Text1.Text & "8"
End Sub
Private Sub cmd9_Click()
Text1.Text = Text1.Text & "9"
End Sub
Private Sub cmdadd_Click()
numero1 = Val(Text1.Text)
Text1.Text = ""
operación = "+"
End Sub
Private Sub cmdce_Click()
Text1.Text = ""
End Sub
Private Sub cmddivide_Click()
numero1 = Val(Text1.Text)
Text1.Text = ""
operación = "/"
End Sub
Private Sub cmdequal_Click()
numero2 = Val(Text1.Text)
If operacion = "+" Then
resultado = numero1 + numero2
ElseIf operacion = "-" Then
resultado = numero1 - numero2
ElseIf operacion = "*" Then
resultado = numero1 * numero2
ElseIf operacion = "/" Then
resultado = numero1 / numero2
End If
Text1.Text = resultado
End Sub
Private Sub cmdminus_Click()
numero1 = Val(Text1.Text)
Text1.Text = ""
operación = "-"
End Sub
Private Sub cmdmultiply_Click()
numero1 = Val(Text1.Text)
Text1.Text = ""
operación = "*"
End Sub
Private Sub cmdpoint_Click()
Text1.Text = "."
End Sub
Valora esta pregunta


0