Free-form Function Input

to calculate a function input from a form, replace the variable placeholder with the actual value (each time through the loop) and use the VBA function Evaluate to produce the calculation.

Function eval_func(ByVal strfunc As String, x As Double) As Double
On Error GoTo HandlError

strfunc = Replace(strfunc, "x", x)
eval_func = Evaluate(strfunc)

ExitHere:
Exit Function
'runtime error 13 type mismatch
HandlError:
If Err.number = 13 Then
MsgBox "type mismatch probably div by zero"
eval_func = ylim + 1
End If

End Function

screenshot_1-3-2016_9

screenshot_1-3-2016_3

Bell Curve
screenshot_1-3-2016_4

screenshot_1-3-2016_6

screenshot_1-3-2016_7

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s