Quote:

> >I'm trying to take user input to create a mathematical function of a

> >variable (ex: "X^2" "-X + 2" run of the mill f(x)'s) by taking input

> >from a text box as a string, searching for the variable and replacing

> it

> >with the correct value. I need it to return a numeric value though.

> So

> >I thought val() would work well. It doesn't though.

> >For example,

> >val(1 + 2) ' would return 3, val(4^2 + 5) would return 21, and so on

> >But...

> >n = "1 + 2"

> >val(n) ' returns "1"

> >n = "4^2 + 5"

> >val(n) ' returns "4"

> >It seems to return the first number in the string. Does anyone know

> how

> >to remedy this? Is there a better way that I could go about

> >accomplishing my goal?

> You are asking for a "recursive descent parser". These have been written

> for VB; some small enough to fit in a VB Class, but there's another way.

> VB always has a database close at hand. Open a connection to it, and

> execute a line like this:

> rs = db.OpenRecordset ("select 4^2 + 5")

> With a little fudging you should be able to beat 21 out of

> 'rs.Fields(0).Value'.

> -- Phlip (no replies - address munged)

> ======= http://users.deltanet.com/~tegan/home.html =======

> -- Programming Without Tan Lines, Inc. --

> >Thanks

A parser is exactly what I'm trying to avoid writing :)

I'm not terribly experienced or skilled at using databases, how would I

go about doing what you were explaining? I tried it, but I was getting

errors like object required (so i put a data control on the form) and

then got "object variable or with block variable not set"

It sounds like I need to have a database file to work with, but I'm not

sure how exactly to go about doing that (I don't have Access, but I do

have Excel 97), plus I'm not too keen on bringing a whole other file

into the picture.

Thanks again.