Solved

JavaScript from VB

Posted on 2003-10-27
2
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 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