Código fuente de 'Calculadora 3.asp'

    <HTML>
    <HEAD>
    <TITLE>Calculadora 3 - Códigos asp, programacion asp, descargas asp, rutinas asp</title>
    </HEAD>

    <BODY BGCOLOR=FFFFFF LINK=#0033CC TOPMARGIN=15 LEFTMARGIN=20>

    <FONT SIZE=3 FACE="Verdana, Arial, Helvetica"> 
    <p align="center">
    <b><font face="Arial">Calculadora 3</font></b></p>
    <!-- global default -->
    
       <CENTER>
    
    <SCRIPT LANGUAGE="VBScript">
    <!-- 
    ' Module-level variables
    ' Previous number (operand) awaiting operation
    Dim Accum		
    ' Flag To indicate a new number (operand) is being entered
    Dim FlagNewNum		
    ' Pending operation waiting For completion of second operand
    Dim PendingOp		
    Sub NumPressed(Byval Num)
    	if FlagNewNum Then
    		Document.Keypad.Readout.Value = Num
    		FlagNewNum = False
    	Else
    		if Document.Keypad.Readout.Value = "0" Then
    			Document.Keypad.Readout.Value = CStr(Num)
    		Else
    			Document.Keypad.ReadOut.Value= Document.Keypad.ReadOut.Value & CStr(Num)
    		End if
    	End if
    End Sub
    Sub Decimal_onClick()
    Dim curReadout
    	curReadOut = Document.Keypad.ReadOut.Value
    	if FlagNewNum Then
    		curReadOut = "0."
    		FlagNewNum = False
    	Else
    		if InStr(curReadOut, ".") = 0 Then
    			curReadOut = curReadOut & "."
    		End if
    	End if
    	Document.Keypad.ReadOut.Value = curReadOut
    End Sub
    Sub Plus_onClick()
    	Operation "+"	
    End Sub
    Sub Minus_onClick()
    	Operation "-"
    End Sub
    Sub Multiply_onClick()
    	Operation "*"
    End Sub
    Sub Divide_OnClick()
    	Operation "/"
    End Sub
    Sub Operation(Byval Op)
    Dim Readout
    	ReadOut = Document.Keypad.ReadOut.Value
    	if FlagNewNum and PendingOp <> "=" Then
    		' User is hitting op keys repeatedly, so don't do anything
    	Else
    		FlagNewNum = True
    		Select Case PendingOp
    		Case "+"
    			Accum = CDbl(Accum) + CDbl(ReadOut)
    		Case "-"
    			Accum = CDbl(Accum) - CDbl(ReadOut)
    		Case "/"
    			Accum = CDbl(Accum) / CDbl(ReadOut)
    		Case "*"
    			Accum = CDbl(Accum) * CDbl(ReadOut)
    		Case Else
    			Accum = ReadOut
    		End Select
    		Document.Keypad.ReadOut.Value = Accum
    		PendingOp = Op
    	End if
    End Sub
    Sub ClearEntry_onClick()
    ' Remove current number and reset state
    Document.Keypad.ReadOut.Value = "0"
    FlagNewNum = True
    End Sub
    Sub Clear_onClick()
    ' Clear accumulator and pending operatio
    '     n, and clear display
    	Accum = 0
    	PendingOp = ""	
    	ClearEntry_onClick
    End Sub
    Sub Neg_onClick()
    	Document.Keypad.ReadOut.Value = CDbl(Document.Keypad.ReadOut.Value) * -1
    End Sub
    Sub Percent_onClick()
    	Document.Keypad.ReadOut.Value = (CDbl(Document.Keypad.ReadOut.Value) / 100) * Accum
    End Sub
    Sub Equals_OnClick()
    	Operation "="
    End Sub
    -->
    </SCRIPT>
    
    
    <FORM action="" Name="Keypad">
    <TABLE>
    <B>
    <TABLE BORDER=2 WIDTH=50 HEIGHT=60 CELLPADDING=1 CELLSPACING=5>
    <CAPTION ALIGN=top>
    	<P>
    	
    </CAPTION>
 
    <TR>
    	<TD COLSPAN=3 ALIGN=MIDDLE><INPUT NAME="ReadOut" TYPE="Text" SIZE=24 VALUE="0" WIDTH=100%></TD>
    	<TD></TD>
    	<TD><INPUT NAME="Clear" TYPE="Button" VALUE=" C " ></TD>
    	<TD><INPUT NAME="ClearEntry" TYPE="Button" VALUE=" CE " ></TD>
    </TR>
    <TR>
    	<TD><INPUT NAME="Seven" TYPE="Button" VALUE=" 7 " OnClick="NumPressed(7)"></TD>
    	<TD><INPUT NAME="Eight" TYPE="Button" VALUE=" 8 " OnClick="NumPressed(8)"></TD>
    	<TD><INPUT NAME="Nine" TYPE="Button" VALUE=" 9 " OnClick="NumPressed(9)"></TD>
    	<TD></TD>
    	<TD><INPUT NAME="Neg" TYPE="Button" VALUE=" +/- " ></TD>
    	<TD><INPUT NAME="Percent" TYPE="Button" VALUE=" % " ></TD>
    </TR>
    
    <TR>
    	<TD><INPUT NAME="Four" TYPE="Button" VALUE=" 4 " OnClick="NumPressed(4)"></TD>
    	<TD><INPUT NAME="Five" TYPE="Button" VALUE=" 5 " OnClick="NumPressed(5)"></TD>
    	<TD><INPUT NAME="Six" TYPE="Button" VALUE=" 6 " OnClick="NumPressed(6)"></TD>
    	<TD></TD>
    	<TD ALIGN=MIDDLE><INPUT NAME="Plus" TYPE="Button" VALUE=" + " ></TD>
    	<TD ALIGN=MIDDLE><INPUT NAME="Minus" TYPE="Button" VALUE="-" ></TD>
    </TR>
    <TR>
    	<TD><INPUT NAME="One" TYPE="Button" VALUE=" 1 " OnClick="NumPressed(1)"></TD>
    	<TD><INPUT NAME="Two" TYPE="Button" VALUE=" 2 " OnClick="NumPressed(2)"></TD>
    	<TD><INPUT NAME="Three" TYPE="Button" VALUE=" 3 " OnClick="NumPressed(3)"></TD>
    	<TD></TD>
    	<TD ALIGN=MIDDLE><INPUT NAME="Multiply" TYPE="Button" VALUE=" * " ></TD>
    	<TD ALIGN=MIDDLE><INPUT NAME="Divide" TYPE="Button" VALUE="/" ></TD>
    </TR>
    <TR>
    	<TD><INPUT NAME="Zero" TYPE="Button" VALUE=" 0 " OnClick="NumPressed(0)"></TD>
    	<TD><INPUT NAME="Decimal" TYPE="Button" VALUE=". " ></TD>
    	<TD COLSPAN=3></TD>
    	<TD><INPUT NAME="Equals" TYPE="Button" VALUE=" = "></TD>
    </TR>
    </TABLE>
    </TABLE>
    </B>
    </FORM>

    </BODY>
    </HTML>