Results 1 to 2 of 2

Thread: Convert String to Math function/expression!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    3

    Question Convert String to Math function/expression!!

    Hi,

    What I'm looking to do is this:

    label1.caption = 25 * textbox1.text
    where textbox1.text = "Cos(45.0)"

    I'm trying to use the string "Cos(45.0)" in a calculation to obtain a numerical value. However, I can't seem to get it to recognise that the string is a math expression. The return value is zero when using Val(textbox1.text).

    Please help!

    Thanks

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Convert String to Math function/expression!!

    Add (from Components dialog) Microsoft Script Control to your project and then to your form.
    When you done you can use like this:
    Code:
    Private Sub Command1_Click()
        Label1.Caption = 25 * ScriptControl1.Eval(Text1.Text)
    End Sub

Tags for this Thread

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