Monday, 22 July 2013

Make Speaking VBS Calculator

Here is a trick for you all friends to make your own speaking calculator in VBS windows script.


1.Open Notepad
2.Copy all below coding into notepad:


Dim expr,sapi, mul, div, add,subtr, op1, op2, typ, pow, moduon error resume nextErr.Clearset sapi = CreateObject("sapi.spvoice")expr=InputBox("Write an expression to calculate: "+vbcrlf+vbcrlf+"Note: Please enter only two operands."+vbcrlf+vbcrlf+"Example: 5+7","Speaking Calculator")mul=split(expr,"*")div=split(expr,"/")add=split(expr,"+")subtr=split(expr,"-")pow=split(expr,"^")modu=split(expr,"mod")
if(ubound(mul)=1)thentyp="mul"op1=mul(0)op2=mul(1)elseif(ubound(div)=1)thentyp="div"op1=div(0)op2=div(1)elseif(ubound(add)=1)thentyp="add"op1=add(0)op2=add(1)elseif(ubound(subtr)=1)thentyp="subtr" op1=subtr(0)op2=subtr(1)elseif(ubound(pow)=1)thentyp="pow" op1=pow(0)op2=pow(1)elseif(ubound(modu)=1)thentyp="mod" op1=modu(0)op2=modu(1)end ifend if end ifend ifend ifend if
if(typ="" or not isnumeric(op1) or not isNumeric(op2))thenmsgbox "The expression you entered seems to be invalid",vbokonly,"Invalid Expression"elseselect case typcase "mul": sapi.Speak replace(expr,"*",": multiplied by ")+": is equal to "+ cStr(Eval(expr))case "div": sapi.Speak replace(expr,"/",": divided by ")+": is equal to "+ cStr(Eval(expr))case "add": sapi.Speak replace(expr,"+",": plus ")+": is equal to "+ cStr(Eval(expr))case "subtr": sapi.Speak replace(expr,"-",": minus ")+": is equal to "+ cStr(Eval(expr))case "pow": sapi.Speak replace(expr,"^",": powered by ")+": is equal to "+ cStr(Eval(expr))case "mod": sapi.Speak replace(expr,"mod",": modulo ")+": is equal to "+ cStr(Eval(expr))end selectend ifif Err.Number <> 0 then msgbox "Description: "+Err.Description,vbokonly,"Error"end if
4.Save file as anything.vbs (.vbs extension  must be there)
You have make a speaking calculator. Enter your question and press ok it will speak question with it'z answer.


1 comment:

  1. this doesn't work it says some error



Visitors Info.

You are from
%%v_FLG%% %%v_IP%%
%%v_CR%% ,%%v_RG%%, %%v_CI%%
%%v_OS_IMG%% %%v_OS%%
%%v_BRW_IMG%% %%v_BRW%%
%%v_I_RESO%% %%v_RESO%% %%v_I_CLR%% %%v_CLR%% Webutation Creative Commons License
Hacker Konka by Konka Karthik is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
Back To Top