
Calculadora Digital
Publicado por Micki (9 intervenciones) el 31/10/2013 19:56:44
TENGO UN FORMULARIO DE UNA CALCULADORA,
ME SALE ESTE ERROR "Los metodos y eventos no pueden contener procedimientos o definiciones de clases anidadas" al momento de ejecutarlo, ESTE ES EL 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
*Crea un formulariofrmMiForm=CreateObject("frmCalculadora")
*Mostrar el formularaiofrmMiForm.Show*Inicia el procesamiento de eventosRead events
Define Class frmCalculadora As form
Procedure Init
Public nValor1, nValor2, puntdeci,cálculorealizado,entero,operador
thisform.TextMOSTRAR.value="0,"
nValor1=0nValor2=0puntdeci=.T.
entero=.T.
EndProc
Procedure Boton.ClickParameter nIndex
Do case
Case InList(nIndex,1,2,3,4,5,6,7,8,9)
thisform.MOSTRAR(Alltrim(str(nIndex)))
Case nIndex=10thisform.MOSTRAR("0")
Case nIndex=11nValor1=val(thisform.TextMOSTRAR.value)
operador="/"
Case nIndex=12nValor1=val(thisform.TextMOSTRAR.value)
operador="*"
Case nIndex=13nValor1=val(thisform.TextMOSTRAR.value)
operador="-"
Case nIndex=14nValor1=val(thisform.TextMOSTRAR.value)
operador="+"
Case nIndex=15if puntdeci=.T.
thisform.TextMOSTRAR.value=thisform.TextMOSTRAR.value+"."
puntdeci=.F.
entero=.F.
endif
Case nIndex=16if entero=.T.
ThisForm.TextMOSTRAR.value=str(val(ThisForm.TextMOSTRAR.Value)*(-1))
Else
ThisForm.TextMOSTRAR.value=str(val(ThisForm.TextMOSTRAR.Value)*(-1),8,3)
Endif
Case nIndex=17ThisForm.TextMOSTRAR.Value="0"
Puntdeci=.T.
nValor1=0 nValor2=0calculorealizado=.T.
entero=.T.
Case nIndex=18nValor2=VAL(ThisForm.TextMOSTRAR.Value)
Do Case
Case operador="+"
if entero=.F.
ThisForm.TextMOSTRAR.Value=str(nValor1+nValor2,8,3)
Else
ThisForm.TextMOSTRAR.Value=str(nValor1+nValor2)
Endif
Case operador="-"
if entero=.F.
ThisForm.TextMOSTRAR.Value=str(nValor1-nValor2,8,3)
Else
ThisForm.TextMOSTRAR.Value=str(nValor1-nValor2)
Endif
Case operador="*"
if entero=.F.
ThisForm.TextMOSTRAR.Value=str(nValor1*nValor2,8,3)
Else
ThisForm.TextMOSTRAR.Value=str(nValor1*nValor2)
Endif
Case operador="/"
if nValor2<>0
if nValor1%nValor2=0
ThisForm.TextMOSTRAR.Value=str(nValor1/nValor2)
Else
ThisForm.TextMOSTRAR.Value=str(nValor1/nValor2,8,3)
Endif
Else
ThisForm.TextMMOSTRAR.Value="Imposible dividir por cero"
Endif
Endcase
calculorealizado=.T.
Case Index=19Clear Events
EndCase
EndProc
Procedure Boton.LostFocusParameter nIndex
Do Case
Case InList(nIndex,11,12,13,14)
Puntdeci=.T.
ThisForm.TextMOSTRAR.Value=Space(14)
Case nIndex=17 nValor1=0 nValor2=0ThisForm.TextMOSTRAR.Value=Space(8)
calculorealizado=.T.
EndCase
EndPro
Procedure Mostrar
Parameter cNumero
if calculorealizado=.T.
ThisForm.TextMOSTRAR.Value=Space(14)
calculorealizado=.F.
Endif
ThisForm.TextMOSTRAR.Value=ThisForm.TextMOSTRAR.Value+cNumero
EndProc
EndDefine
ESTE ES LA MASCARA

Valora esta pregunta


0