Sunday 16 June 2013

Make Speaking VBS Calculator


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

Tutorial:-


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)
5.Done

You have make a speaking calculator. Enter your question and press ok it will speak question with it'z answer.

Enjoy(0_0)
Share this post
  • Share to Facebook
  • Share to Twitter
  • Share to Google+
  • Share to Stumble Upon
  • Share to Evernote
  • Share to Blogger
  • Share to Email
  • Share to Yahoo Messenger
  • More...

1 comments

:) :-) :)) =)) :( :-( :(( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ :-$ (b) (f) x-) (k) (h) (c) cheer

 
© HaCkErZ-PoSiTiVe
Designed by VINOD
Back to top
© HaCkErZ-PoSiTiVe - About | Privacy | Contact | Sitemap