Results 1 to 6 of 6

Thread: Invoke VBScript from VB.NET

  1. #1

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Invoke VBScript from VB.NET

    Hi

    I classic VB6 you can place the script control on a form, load VBScript into it and excecute. You can also share objects between VB6 and VBScript. I want to achieve the same thing but with VB.NET. My objective is to write a VB.NET application that will run some queries against a database, build some object collections, load some VBScript code and manipulate the object from VBScript. The objective is to have configurable vbscripts to easily format the data from the object. Could someone point me to some links where I can learn soemthing about it.



    Thanks
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  2. #2
    Addicted Member
    Join Date
    Jun 2005
    Posts
    175

    Re: Invoke VBScript from VB.NET

    I'm not QUITE sure if it's what you're looking for, but VB.NET DOES allow you to encapsulate another program as a process. Look up the Process control under Components in the Tool Box in the VB.NET IDE.

  3. #3
    Addicted Member
    Join Date
    Jun 2005
    Posts
    175

    Re: Invoke VBScript from VB.NET

    As an extra note about the Process control, you can even specify arguments to pass to the process, as if you were executing the process at a cmd line.

  4. #4
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: Invoke VBScript from VB.NET

    Mr.No:

    I would suggest that you might have some problems due to the changes in the Visual Basic.Net syntax as set out below:

    Visual Basic Syntax
    The following list describes specific changes in Visual Basic .NET that might require changes to existing Visual Basic or VBScript applications.

    The data type Variant no longer exists. It has been replaced with the type Object. Object types must be explicitly cast to other primitive data types.
    Parentheses are now required around the parameter list in all method calls, even for methods that do not take parameters. For example:
    If Flag = False Then
    DisplayMessage()
    End If

    By default, arguments are passed by value, not by reference as in previous versions of Visual Basic. If you want to pass arguments by reference, you must use the ByRef keyword in front of the argument, as in the following example:
    Call MyFunction(argbyvalue, ByRef argbyref)

    Set and Let are no longer supported. Objects can be assigned by a simple assignment operation:
    Object1 = Object2

    To set a default property of an object, you must now explicitly reference the property. For example:

    Object1.Name = Object2.NameMost objects no longer have assumed default properties. All non-indexed properties must be explicitly referenced. In previous versions of Visual Basic, if you wanted to access the default property of an object, specifying the name of the default property was optional. For example, if you wanted to access the Text property of a TextBox control, you could use the following code:
    Dim str As String = TextBox1

    Because the default property of the TextBox control was the Text property. Using Visual Basic .NET, the above code must be modified as follows:

    Dim str As String = TextBox1.Text

    If default properties were allowed in Visual Basic .NET, an expression such as

    Object1 = Object2

    would be ambiguous because it is not clear whether Object2 refers to the object in its entirety or just to the default property of the object.

    As another example, you must explicitly reference the Value property of the Field object when retrieving fields from a Recordset (RS in the following example):

    Response.Write ( Server.HtmlEncode(RS("au_fname").Value))
    Indexed default properties are supported if the class contains a definition for an indexed property. The following expression is valid because the indexer makes it clear that an indexed property, not the object itself, is being referenced:
    MyProperty = Object2(6)

    The Integer data type is now 32 bits; the Long data type is 64 bits.
    Data types should always be explicitly cast to other data types. For instance, always cast numerical values to String if a string is expected:
    Response.Write("The count is " & CStr(count))

    Variables created within the same Dim statement will be of the same type. For example, in Visual Basic .NET, the Dim statement Dim i, j, k As Integer creates each of the three objects (i, j, and k) as an Integer. Previous versions of Visual Basic would create i and j as Variants and k as an Integer.
    Class property syntax has changed and no longer includes Property Let, Property Get, and Property Set. The new property syntax is similar to that in C#.
    [Visual Basic]
    Public Property ThisProperty As String
    Get
    ThisProperty = InternalValue
    End Get
    Set
    InternalValue = value
    End Set
    End Property

    Spaces must always be included around the & operator when concatenating strings. VBScript allowed you to write a&b&c; in Visual Basic. NET this must be written as a & b & c to avoid a syntax error.
    All If statements must be constructed on multiple lines. With VBScript, it was possible to write a single-line If statement such as If x Then y. In Visual Basic .NET, this must be written as follows:
    If x Then
    y
    End if

    Option Explicit is on by default, so all variables must be declared before they can be used.


    Hope this helps a little.

  5. #5

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Re: Invoke VBScript from VB.NET

    Thanks for the reply 2bigfeet23.

    I want to be able to share objects between VB.NET and the VBScript script i.e. the VB.NET passes a bunch of data to the script which formats and outputs and then raises and event to the VB.NET.

    Thanks
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

  6. #6

    Thread Starter
    Fanatic Member Mr.No's Avatar
    Join Date
    Sep 2002
    Location
    Mauritius
    Posts
    651

    Re: Invoke VBScript from VB.NET

    AIS4U thanks for your input.
    Using VB.NET 2003/.NET 1.1/C# 2.0
    http://del.icio.us/rajoo
    Blow your mind, smoke gunpowder
    Ashes to ashes, dust to dust
    If God won't have you, the devil will. - Author unknown
    Don't follow me, I'm lost too ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width