Results 1 to 5 of 5

Thread: How can turn a string formula into its numeric value?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Question How can turn a string formula into its numeric value?

    hi guys
    well during the code we can have:


    dim a as integer

    a=val( Inputbox("Number?"))

    x=a^2+3*sin(2*a) 'some formula

    but what if i want to ask the user for the formula? for example the user enters the formula in a textbox and i use the formula to get the value of x above. or simply if the user enter's "2*3^2/5" (as a string ) then i can have the answer. is it possiable?

  2. #2
    Frenzied Member agmorgan's Avatar
    Join Date
    Dec 2000
    Location
    Lurking
    Posts
    1,383
    I would have thought you just need a routine to look for key characters
    e.g examine the string char by char, ASCII 40 to 47 have maths operators I think

  3. #3

  4. #4
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    Add 'Microsoft Access 8.0 Object Library' to your project's reference and use code like this

    myString = "((3+5)*4)-(40/2)-10)"
    MsgBox Eval(myString)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Thumbs up

    Originally posted by phinds
    Add 'Microsoft Access 8.0 Object Library' to your project's reference and use code like this

    myString = "((3+5)*4)-(40/2)-10)"
    MsgBox Eval(myString)
    thanks guys. u really helped a lot. I added Ms Script contorl and it worked perfect. i tried 'Microsoft Access 8.0 Object Library' too but i recived 'error in loading DLL' error at run time. i don't know why
    anyway thanks alot

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