Pass variables between VBScript and VB.net ?

R

Rob

Is there a way to pass data between VBscript and a VB.net form ?

For example...,

Open a VB.net form , enter a value in a text box, then run a VBscript that
returns the value entered in the textbox via a VBScript message box.

I have seen some samples that are close to working... they return a value
that was hardcoded into the VB.net Class Library program.

By creating a Class library as follows... and Building the project....

Imports System.Runtime.InteropServices

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "3c6c34ac-2447-4749-95c5-322afdc446fc"
Public Const InterfaceId As String =
"6cb9c355-2831-4ab2-9da1-625a445fa694"
Public Const EventsId As String = "99651d78-3838-4965-b2b8-e75099caa1cc"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Public Function myFunction() As String

Return "Happy Day !"

End Function
End Class

THEN.... By running the following VBScript.... you get the desired result...
(at least part of the way)

Dim myObject
Set myObject = CreateObject("ClassLibrary1.COMClass1")
MsgBox myObject.myFunction


HOWEVER... Now I need to know how to make it work dynamically with a vb.net
form. I think I must create another project (somehow link to the class
library) and also change the ClassLibrary to return the value entered in the
vb.net form (as opposed to the hard-coded value).

Any thought on how to proceed from this point ?
 
R

rowe_newsgroups

Is there a way to pass data between VBscript and a VB.net form ?

For example...,

Open a VB.net form , enter a value in a text box, then run a VBscript that
returns the value entered in the textbox via a VBScript message box.

I have seen some samples that are close to working... they return a value
that was hardcoded into the VB.net Class Library program.

By creating a Class library as follows... and Building the project....

Imports System.Runtime.InteropServices

<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1

#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "3c6c34ac-2447-4749-95c5-322afdc446fc"
Public Const InterfaceId As String =
"6cb9c355-2831-4ab2-9da1-625a445fa694"
Public Const EventsId As String = "99651d78-3838-4965-b2b8-e75099caa1cc"
#End Region

' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub

Public Function myFunction() As String

Return "Happy Day !"

End Function
End Class

THEN.... By running the following VBScript.... you get the desired result...
(at least part of the way)

Dim myObject
Set myObject = CreateObject("ClassLibrary1.COMClass1")
MsgBox myObject.myFunction

HOWEVER... Now I need to know how to make it work dynamically with a vb.net
form. I think I must create another project (somehow link to the class
library) and also change the ClassLibrary to return the value entered in the
vb.net form (as opposed to the hard-coded value).

Any thought on how to proceed from this point ?

I don't understand why you want or need to do this? There is very
little (if any) functionality that VBS has that can't be duplicated
using Visual Basic .Net. I would say you are simply asking for trouble
by doing this.

If however you have an excellent reason for using VBS, I would
recommend you pass the necessary variable(s) as commandline parameters
to the vb script.

Thanks,

Seth Rowe
 
R

Rob

Hi Seth,

There exists an ERP package that is not a .net app that allows for passing
variables between vbscript and it forms. We want to use some feature rich
vb.net forms and pass the results back to the vbscript form... which can
then be passed back to the ERP's form.

Thanks !
 
R

Rob

Seth,

Would it be better to store the values in xml and pass them back and forth
that way ?

Thanks,
Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top