From: david.didonato on
hallo zusammen

i use the script control, but i have a big problem.
here is my source code

Class cEval:
==========
Function vEval(ByVal Expression As String) As Variant

Dim osc As New MSScriptControl.ScriptControl

On Error GoTo OnError

osc.Language = "VBScript"
vEval = CVar(osc.Eval(Expression))

OnExit:
Exit Function

OnError:
vEval = Err.Description
Resume OnExit

End Function

-----------------------------------------
Klasse cMath
==========
Public Function Frac(ByVal f As Double) As Double
' Example: Frac(2.56) = 0.56
'
Frac = f - Fix(f)
End Function
--------------------------------------------
now, i made a function "xTest"

Function xTest()

Dim e_ As New cEval
s = "Frac(111.2123545)"
Debug.Print e_.vEval(s)
End Sub
------------------------------------------

i receive always the error message "type mismatch: Frac"....what's
wrong ? i think he can find the function FRAC....Please help me....

Gruss
david

From: Steve Gerrard on

<david.didonato(a)gmail.com> wrote in message
news:1187680552.177771.240490(a)d55g2000hsg.googlegroups.com...
> hallo zusammen
>
>
> i receive always the error message "type mismatch: Frac"....what's
> wrong ? i think he can find the function FRAC....Please help me....
>

It can't find the function FRAC. It is in its own little world.

If you want the script object to use some code, you have to give it the code.

SC1.AddCode _
"Function Frac(f) : " _
& " Frac = f - Fix(f) : " _
& "End Function"

Dim s As String
s = "Frac(111.2123545)"

MsgBox SC1.Eval(s)