Important alert: (current site time 7/15/2013 11:05:00 PM EDT)
 

VB icon

Calculator

Email
Submitted on: 2/23/2000
By: martin castaņeda  
Level: Intermediate
User Rating: By 3 Users
Compatibility: VbScript (browser/client side)
Views: 26055
 
     Show the Math Capabilities of VBScript

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Calculator
' Description:Show the Math Capabilities of VBScript
' By: martin castaņeda
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=6078&lngWId=4'for details.'**************************************

<html>
<center>
<font size=7 color=red>VBScript Calculator<br></font>
<table border=7>
 <tr> 
<td colspan=3 align=middle><input name=display size=30></td>
 </tr>
 <tr> 
<td><input type=button name=one value="1"></td>
<td><input type=button name=two value="2"></td>
<td><input type=button name=three value="3"></td>
 </tr>
 <tr> 
<td><input type=button name=four value="4"></td>
<td><input type=button name=five value="5"></td>
<td><input type=button name=six value="6"></td>
 </tr>
 <tr> 
<td><input type=button name=seven value="7"></td>
<td><input type=button name=eight value="8"></td>
<td><input type=button name=nine value="9"></td>
 </tr>
 <tr> 
<td></td>
<td><input type=button name=zero value="0"></td>
<td></td>
 </tr>
 <tr>
<td><input type=button name=point value="."></td>
<td><input type=button name=plus value="+"></td>
<td><input type=button name=minus value="-"></td>
 </tr>
 <tr> 
<td><input type=button name=multiply value="x"></td>
<td><input type=button name=divide value="/"></td>
<td><input type=button name=equals value="="></td>
 </tr>
 <tr> 
<td></td>
<td><input type=button name=reset value=" reset "></td>
<td></td> 
 </tr> 
</table>
<br>
<a href=index.htm>VBScript Calculator Created by Martin Castaņeda</a>
</font>
</CENTER>
<script language=vbscript>
<!--
dim operator
dim buffer
sub one_onclick
 display.value = display.value + "1"
end sub
sub two_onclick
 display.value = display.value + "2"
end sub
sub three_onclick
 display.value = display.value + "3"
end sub
sub four_onclick
 display.value = display.value + "4"
end sub
sub five_onclick
 display.value = display.value + "5"
end sub
sub six_onclick
 display.value = display.value + "6"
end sub
sub seven_onclick
 display.value = display.value + "7"
end sub
sub eight_onclick
 display.value = display.value + "8"
end sub
sub nine_onclick
 display.value = display.value + "9"
end sub
sub zero_onclick
 display.value = display.value + "0"
end sub
sub point_onclick
 display.value = display.value + "."
end sub
sub plus_onclick
 call determine 
 operator="plus"
 display.value=""
end sub
sub minus_onclick
 call determine
 operator="minus"
 display.value=""
end sub
sub multiply_onclick
 call determine
 operator="multiply"
 display.value=""
End sub
sub divide_onclick
 call determine
 operator="divide"
 display.value=""
End sub
sub equals_onclick
 call determine
 operator=""
 display.value=buffer
end sub
sub reset_onclick
 call initialize
end sub
sub initialize
 buffer=""
 operator=""
 display.value=""
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=csng(display.value)
 if operator="plus" then result = csng(buffer) + csng(display.value)
 if operator="minus" then result = csng(buffer) - csng(display.value)
 if operator="multiply" then result = csng(buffer) * csng(display.value)
 if operator="divide" then result = csng(buffer) / csng(display.value)
 buffer=result 
end sub
-->
</script>
</html>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
3/5/2002 11:13:55 PMnsubramanian

hai
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.