Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Control Integration 1

Status
Not open for further replies.

mansii

Programmer
Oct 18, 2002
641
ID
Hi All,
I'm not sure if this forum is the right place to throw my problem.

VB 2005
Refference : MS Script Control

I have this simple equation:
Code:
Dim str2Eval As String = "1.1 + 2.2 = 3.3"
Dim sscript As New MSScriptControl.ScriptControl
sscript.Language = "VBScript"
Try
    Label1.Text = sscript.Eval(str2Eval)
Catch ex As Exception
    Label1.Text = Label1.Text = ex.Message
    Exit Try
End Try
But The result is False.

I tried to evaluate the left side of the equation which gives me the desired result:
Code:
Dim str2Eval As String = "1.1 + 2.2"
..
Label1.Text = sscript.Eval(str2Eval)
'gives me 3.3

No problem with integers.
Any help would be appreciated.
 
After several workarounds, I came to this solution:
Code:
Dim str2Eval As String = "1.1 + 2.2"
Dim str2Eval2 As String = "3.3"
..
Label1.Text = sscript.Eval(str2Eval & "=" & str2Eval2)

Which gave a True result.
But the question remains.

Regards.
 
A couple of things:

=====

Are you sure that this is what you intended?

[tt]Label1.Text = Label1.Text = ex.Message[/tt]

and not:

[tt]Label1.Text = ex.Message[/tt]

=====

Try this:

[tt]Label2.Text = (1.1 + 2.2 = 3.3).ToString[/tt]


Notice it also returns False

=====


You are dealing with inaccurate numbers (doubles and singles). Make them accurate and you will get the desired result as in:

[tt]Dim str2Eval As String = "CCur(1.1) + CCur(2.2) = CCur(3.3)"[/tt]


Hope this helps.







[vampire][bat]
 
EnF,
First thing is a typo.
I agree with second thing.
And the last line is the thing that I long for.

Thank's. A star for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top