Coma en calculadora
Supongo que si programas en fox programaras en visual basic, espero que me ayudes, es muy urgente. Mira debo ser idiota porque no se como hacer que en mi calculadora pueda calcular con decimales, no se introducir la coma sin que se vaya el número anterior, ¿mira te pongo el código oki?
Option Explicit
Dim T1 As String
Dim Op As String
Dim F1 As Double
Dim res As Double
Private Sub cambio_Click(Index As Integer)
txt1 = txt1 * -1
End Sub
Private Sub Cmdc_Click()
txt1.Text = ""
End Sub
Private Sub cmdce_Click()
txt1.Text = "0"
T1 = ""
F1 = ""
Op = ""
End Sub
Private Sub Cmdigual_Click()
If Op <> "" Then
If Op = 0 Then
res = Val(F1) + Val(T1)
ElseIf Op = 1 Then
res = Val(F1) - Val(T1)
ElseIf Op = 2 Then
res = Val(F1) * Val(T1)
ElseIf Op = 4 Then
If T1 = 0 Then
res = "E"
Else
res = Val(F1) / Val(T1)
End If
End If
txt1.Text = res
T1 = ""
F1 = res
Op = ""
End If
End Sub
Private Sub cmdoff_Click(Index As Integer)
Unload Me
End Sub
Private Sub com_Click(Index As Integer)
txt1.Text = ","
End Sub
Private Sub num_Click(Index As Integer)
T1 = T1 & Index
txt1.Text = T1
End Sub
Private Sub oper_Click(Index As Integer)
F1 = txt1.Text
T1 = ""
Op = Index
End Sub
Private Sub txt1_Change()
txt1.Locked = True
End Sub
Gracias
Option Explicit
Dim T1 As String
Dim Op As String
Dim F1 As Double
Dim res As Double
Private Sub cambio_Click(Index As Integer)
txt1 = txt1 * -1
End Sub
Private Sub Cmdc_Click()
txt1.Text = ""
End Sub
Private Sub cmdce_Click()
txt1.Text = "0"
T1 = ""
F1 = ""
Op = ""
End Sub
Private Sub Cmdigual_Click()
If Op <> "" Then
If Op = 0 Then
res = Val(F1) + Val(T1)
ElseIf Op = 1 Then
res = Val(F1) - Val(T1)
ElseIf Op = 2 Then
res = Val(F1) * Val(T1)
ElseIf Op = 4 Then
If T1 = 0 Then
res = "E"
Else
res = Val(F1) / Val(T1)
End If
End If
txt1.Text = res
T1 = ""
F1 = res
Op = ""
End If
End Sub
Private Sub cmdoff_Click(Index As Integer)
Unload Me
End Sub
Private Sub com_Click(Index As Integer)
txt1.Text = ","
End Sub
Private Sub num_Click(Index As Integer)
T1 = T1 & Index
txt1.Text = T1
End Sub
Private Sub oper_Click(Index As Integer)
F1 = txt1.Text
T1 = ""
Op = Index
End Sub
Private Sub txt1_Change()
txt1.Locked = True
End Sub
Gracias
1 respuesta
Respuesta de igordillo
1