Solved

JavaScript from VB

Posted on 2003-10-27
2
158 Views
Last Modified: 2012-05-04
Hi Experts,

I have JavaScript program in My.JS file located in some folder.
I need to build VB executable that once is started it executes My.JS file.



Thank you.
0
Comment
Question by:fpoyavo
2 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 500 total points
ID: 9628655
what does your js file do?

e.g., you might be able to do something like this...

make a reference to microsoft script control under project/references then:

Dim scr As New MSScriptControl.ScriptControl
Dim strJS As String

Dim ff As Integer

ff = FreeFile
Open "C:\documents and settings\bob\my documents\test.js" For Input As #ff
strJS = Input(LOF(ff), ff)
Close (ff)

scr.Language = "javascript"
scr.AddCode strJS

scr.AllowUI = True

'' this is what is in test.js
'function addNumbers(i1, i2) {
'   return i1 + i2;
'}
'
'function multNumbers(i1, i2) {
'   return i1 * i2;
'}

'' just show the number of procedures we've added
MsgBox scr.Procedures.Count


'' run examples
Dim res As Double
res = scr.Eval("addNumbers(5, 25)")
MsgBox res
res = scr.Eval("multNumbers(5, 25)")
MsgBox res

'' you could also try doing, scr.run strJS

Set scr = Nothing
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9629259
i think ....
dim wsh
set wsh=createobject("wscript.shell")
wsh.run "c:\myfile.js"
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question