Operaciones con decimales
Holas, mi problemilla es que estoy haciendo una calculadora en asp y no he podido hacer que funcione las operaciones con decimales si me puedes colaborar con esto te agradeceria en el alma te mando el script para que lo revises creo que es mucho mas facil, de todas modos que pena la molestia y gracias por la atención.
<SCRIPT language=vbscript>
<!--
Dim operator, buffer, operation
Sub one_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="1"
if operation=0 Then display.value=display.value+"1"
operation=0
End Sub
Sub two_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="2"
if operation=0 Then display.value=display.value+"2"
operation=0
End Sub
Sub three_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="3"
if operation=0 Then display.value=display.value+"3"
operation=0
End Sub
Sub four_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="4"
if operation=0 Then display.value=display.value+"4"
operation=0
End Sub
Sub five_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="5"
if operation=0 Then display.value=display.value+"5"
operation=0
End Sub
Sub six_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="6"
if operation=0 Then display.value=display.value+"6"
operation=0
End Sub
Sub seven_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="7"
if operation=0 Then display.value=display.value+"7"
operation=0
End Sub
Sub eight_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="8"
if operation=0 Then display.value=display.value+"8"
operation=0
End Sub
Sub nine_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="9"
if operation=0 Then display.value=display.value+"9"
operation=0
End Sub
Sub zero_onclick
if display.value="0" Then display.value=""
if opeation=1 Then display.value="0"
if operation=0 Then display.value=display.value+"0"
operation=0
End Sub
Sub point_onclick
if operation=1 Then display.value="0."
if operation=0 Then display.value=display.value+"."
operation=0
End Sub
Sub plus_onclick
determine()
operator="plus"
operation=1
End Sub
Sub minus_onclick
determine()
operator="minus"
operation=1
End Sub
Sub multiply_onclick
determine()
operator="multiply"
operation=1
End Sub
Sub divide_onclick
determine()
operator="divide"
operation=1
End Sub
Sub equals_onclick
determine()
operator=""
display.value=buffer
operation=1
End Sub
Sub reset_onclick
ready()
End Sub
Sub ready()
buffer=""
operator=""
display.value="0"
End Sub
Sub determine()
Dim result
if Not isnumeric(display.value) Then display.value="0"
if Not isnumeric(buffer) Then buffer="0"
if operator="" Then result=display.value
if operator="plus" Then result = Cdbl(buffer) + Cdbl (display.value): display.value = result
if operator="minus" Then result = csng(buffer) - csng(display.value): display.value = result
if operator="multiply" Then result = csng(buffer) * csng(display.value): display.value = result
if operator="divide" Then result = csng(buffer) / csng(display.value): display.value = result
buffer=result
End Sub
-->
</SCRIPT>
</body>
</html>
<SCRIPT language=vbscript>
<!--
Dim operator, buffer, operation
Sub one_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="1"
if operation=0 Then display.value=display.value+"1"
operation=0
End Sub
Sub two_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="2"
if operation=0 Then display.value=display.value+"2"
operation=0
End Sub
Sub three_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="3"
if operation=0 Then display.value=display.value+"3"
operation=0
End Sub
Sub four_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="4"
if operation=0 Then display.value=display.value+"4"
operation=0
End Sub
Sub five_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="5"
if operation=0 Then display.value=display.value+"5"
operation=0
End Sub
Sub six_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="6"
if operation=0 Then display.value=display.value+"6"
operation=0
End Sub
Sub seven_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="7"
if operation=0 Then display.value=display.value+"7"
operation=0
End Sub
Sub eight_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="8"
if operation=0 Then display.value=display.value+"8"
operation=0
End Sub
Sub nine_onclick
if display.value="0" Then display.value=""
if operation=1 Then display.value="9"
if operation=0 Then display.value=display.value+"9"
operation=0
End Sub
Sub zero_onclick
if display.value="0" Then display.value=""
if opeation=1 Then display.value="0"
if operation=0 Then display.value=display.value+"0"
operation=0
End Sub
Sub point_onclick
if operation=1 Then display.value="0."
if operation=0 Then display.value=display.value+"."
operation=0
End Sub
Sub plus_onclick
determine()
operator="plus"
operation=1
End Sub
Sub minus_onclick
determine()
operator="minus"
operation=1
End Sub
Sub multiply_onclick
determine()
operator="multiply"
operation=1
End Sub
Sub divide_onclick
determine()
operator="divide"
operation=1
End Sub
Sub equals_onclick
determine()
operator=""
display.value=buffer
operation=1
End Sub
Sub reset_onclick
ready()
End Sub
Sub ready()
buffer=""
operator=""
display.value="0"
End Sub
Sub determine()
Dim result
if Not isnumeric(display.value) Then display.value="0"
if Not isnumeric(buffer) Then buffer="0"
if operator="" Then result=display.value
if operator="plus" Then result = Cdbl(buffer) + Cdbl (display.value): display.value = result
if operator="minus" Then result = csng(buffer) - csng(display.value): display.value = result
if operator="multiply" Then result = csng(buffer) * csng(display.value): display.value = result
if operator="divide" Then result = csng(buffer) / csng(display.value): display.value = result
buffer=result
End Sub
-->
</SCRIPT>
</body>
</html>
1 Respuesta
Respuesta de sebillac
1