Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 132,299 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,045 people online right now. Registration is fast and FREE... Join Now!




using msscriptcntrol

 
Reply to this topicStart new topic

using msscriptcntrol

h c gupta
post 19 Feb, 2008 - 10:34 PM
Post #1


New D.I.C Head

*
Joined: 17 Feb, 2008
Posts: 1

While running the following codes in vb2005 ,it gives

'Object does'nt support this property or method:c'




CODE

  Dim a As Integer = 5, b As Integer = 6, s As String = "", c As Integer = 0
        Me.AxScriptControl1.Language = "VBScript"
        Me.AxScriptControl1.Reset()
        s = " c =  a  *  b "

        Me.AxScriptControl1.AddObject("a", a)
        Me.AxScriptControl1.AddObject("b", B)
        Me.AxScriptControl1.AddObject("c", c)
        Me.AxScriptControl1.ExecuteStatement(s)
    
        MsgBox(c.ToString)


I shall be very thankful for being helped to overcome the problem.
h c gupta
User is offlineProfile CardPM

Go to the top of the page

Jayman
post 20 Feb, 2008 - 12:42 AM
Post #2


Student of Life

Group Icon
Joined: 26 Dec, 2005
Posts: 6,839



Thanked 38 times

Dream Kudos: 500

Expert In: C#, VB.NET, Java

My Contributions


Moved to VB.NET.

If you are just trying to use the script control to evaluate an equation, then you want to use the Eval method. Don't include c in the expression. You will use the Eval method to store the result of the expression in c, don't forget you need to convert it to the correct data type.

See how I modified the expression stored in s. On a side note, you should use the .NET version of MessageBox.Show.
Like this:
CODE

        Dim a As Integer = 5, b As Integer = 6, s As String = ""
        Me.AxScriptControl1.Language = "VBScript"
        Me.AxScriptControl1.Reset()
        s = "a  *  b"

        Me.AxScriptControl1.AddObject("a", a)
        Me.AxScriptControl1.AddObject("b", b)
        Dim c As Integer = Convert.ToInt32(Me.AxScriptControl1.Eval(s))
        MessageBox.Show(c.ToString)


This will display a message box with a value of 30.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 01:39AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month