Results 1 to 2 of 2

Thread: Calculation string... in a string

  1. #1

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    Calculation string... in a string

    I got "2 + 2" in a string variable.

    I would like to know if it's possible to actually execute/calculate that STRING to obtain the result of "4".

    I don't feel like parsing/messing with the string, unless I have no choice.

    Thank you!
    Chris

  2. #2
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    499

    Re: Calculation string... in a string

    You can use the Eval Method for that.
    Code:
    'project >> references >> microsoft script control 1.0
    
    Dim msc As New MSScriptControl.ScriptControl
    Dim Str1 As String
    
    Str1 = "2 + 2"
    
    msc.Language = "vbscript"
    
    MsgBox msc.Eval(Str1)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width