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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Callling vbscript modules in vb

Status
Not open for further replies.

dmh4ab

Programmer
Oct 2, 2002
53
US
Can I call vbscript functions form vb code and vice versa?

I have a reference set for Microsoft Scripting Runtime, and I included the .vbs file as a module in the vb project, but within the function it doesn't recognize the control names (ex: document.testform.txtcaseleakage.value).

Any suggestions?

Thanks,
dmh4ab
 
The initial answer to this is Of course you can call VB from VBScript.

If you create a COM object from your VB code you can call it from anywhere.

Now can you call VBScript from within VB...yes you can...if you do it right.

Well the answer to that is yes as well...with some restrictions. Keep in mind that VB is a compiled language and VBScript is a scripting language. In a scripting language you read through things sequentially. Yes you can create functions and yes you can use objects...but not until they are already read. VB compiles everything and makes the objects, then you use them.

So the round about sort of way that I am getting to the answer is this.

You cannot write your VB application in the same way you write a VBscript. You can't simple say "include file1.vbs" and then have access to the code in it.

Take your VBScript code, and copy and paste it into a Module (not a class module) in the VB app that you want to use it it. That will be your simplest way of using it.
 
Thanks! and wow!

As far as calling the vbscript from vb - I have the vbscript in a module like you suggested. The only problem there is the syntax differences btwn vb and vbscript in referencing variables.

Now, as for calling vb from vbscript - I'm a little lost here. I've never done anything like a COM object, but from what I gather, I could just make the project an activeX project and then it would be a COM object??

If it helps any, I basically have a vb form that contains a dhtmledit control. The document in the dhtmledit control is controlled by vbscript. Only prob is.....that some of these procedures need to access the vb form code.

I may be way in left field here, but I'm still new at this and kinda feeling my way through it.

Any help would be greatly appreciated. I'll be glad to provide more info if needed!

Thanks in advance!
dmh4ab
donna.haynes@honeywell.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top