i have written a lot of javascript functions that i want to use in my vb6 app for efficiency and time saving
is it possible to call java-script function from vb6?
if possible, can you help me with some code?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I hesitate to say this, but you could use the Windows Script Control ActiveX control and embed it in your VB6 application and then run your javascript code possibly with some minor adjustments, but DON’T DO IT. You might think it is efficient and time saving for you, but the reality is you will spend all sorts of extra time dealing with your “work around.” Additionally, porting your code to VB6 will make it run much faster. I would only use the scripting method if you need some sort of extensibility.
Add a reference to the scripting runtime and the script control 1.0.
NOTE: in this example the variable scode is the javascript code passed to the function as a string. Since the code is simply a string you can pass in any variables you want, however, getting things back from the code is much more complex. The code can be created on the fly or retrieved from a text file.
In the example, the code is passed as a string and then the string is searched to see if it contains a function called OnProgramLoad. If it does, that function is called.
You would be better off porting your routines to VB6 and if you need access to a regex library in VB6 there are better ways:
http://support.microsoft.com/kb/818802
Add a reference to Microsoft VBScript Regular Expressions 5.5, then port your code…