home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch20 / scripts / math1.vbs < prev    next >
Encoding:
Text File  |  1996-05-12  |  445 b   |  17 lines

  1. ' This script contacts Excel to calculate
  2. ' a math expression and displays the result
  3.  
  4. Set EXL = CreateObject("Excel.Application")
  5. Set Args = Wscript.Arguments
  6. If Args.Count = 0 Then
  7.     Expression = InputBox("Please enter a math expression")
  8. Else
  9.     Expression = Args(0)
  10. End If
  11. On Error Resume Next
  12. MsgBox Expression & " = " & EXL.Evaluate(Expression)
  13. If Err.Number > 0 Then
  14.     MsgBox Err.Description
  15. End If
  16. Set EXL = Nothing
  17.