Results 1 to 6 of 6

Thread: [RESOLVED] Compute expression

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] Compute expression

    Hello.
    Is there any VB function which allows to compute an expression?

    Example:
    In a textbox input:"2+2"

    On button click
    msgbox compute (me.text1)


    Thank you

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Compute expression

    Add a reference to the component: Microsoft Script Control 1.0

    Code:
    Private Sub Command1_Click() 
    Dim script As ScriptControl 
    Set script = New ScriptControl 
    script.Language = "VBScript" 
    Debug.Print script.Eval("2+2")
    End Sub

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Compute expression

    You could add the Microsoft Script Control to your Form and the use code simular to this:
    vb Code:
    1. MsgBox ScriptControl1.Eval(Text1.Text)
    Edit: I'm just too slow today

  4. #4
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Compute expression

    Add a Microsoft Script Control to your components. Add new component to your form. use like
    Code:
    ScriptControl1.Eval("2+2")
    There are some examples here. search and see.
    IIF(Post.Rate > 0 , , )

  5. #5
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Compute expression

    I m damn slow, as usual
    IIF(Post.Rate > 0 , , )

  6. #6

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Compute expression

    Awesome...
    Thank you

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