Private Sub ComOperacion_Click(Index As Integer)
Dim t1 As Single ' para hacer una breve pausa si procede
If Index = 1 Then ' operación de resetear la operación en curso (típicamente llamada Clear)
paso = 1
operando1 = 0
operando2 = 0
Operacion = 0
Text1.Text = ""
Else
If paso = 1 Or paso = 3 Then
If paso = 1 Then
operando1 = Val(Text1.Text)
Text1.Text = ComOperacion(Index).Caption
paso = 2
Operacion = Index
Else
' recogemos el operando 2 y calculamos
Operando2 = Val(Text1.Text)
Text1.Text = Calcular
' el resultado se toma como operand1, salvo que se borre.
Operando1 = Val(Text1.Text)
Paso = 2
Me.Enabled = False
Text1.ForeColor = vbRed
' proporcionamos una espera de 3 segundos para ver el resultado
t1 = Timer
Do
DoEvents
Loop While (Timer - t1) < 2
If Index <> 0 Then ' miramos que operación se ha elegido
Text1.Text = ComOperacion(Index).Caption ' después de la pausa colocamos el nuevo operador en el visor
Operacion = Index
End If
Text1.ForeColor = vbGreen
Me.Enabled = True
End If
Else
Operacion = Index
Text1.Text = ComOperacion(Index).Caption
End If
End If
End Sub