Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3948606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:23:41+00:00 2026-05-20T01:23:41+00:00

i have written a lot of javascript functions that i want to use in

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:23:42+00:00Added an answer on May 20, 2026 at 1:23 am

    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.

    Public Sub OnProgramLoad(byval scode as string)
    Dim sctest As ScriptControl
    
    If Len(scode) < 1 Then Exit Sub
    
    If InStr(1, scode, "OnProgramLoad", vbTextCompare) = 0 Then Exit Sub
    
    Set sctest = New ScriptControl
    
    With sctest
        .Language = "JScript"
        .AllowUI = True
        .AddObject "Application", App
        .AddObject "Clipboard", Clipboard
        .AddObject "Printer", Printer
        .AddObject "Screen", Screen
        .AddCode scode
        .Run "OnProgramLoad"
        End With
    Set sctest = Nothing
    
    End Sub
    

    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…

    Function TestRegExp(myPattern As String, myString As String)
       'Create objects.
       Dim objRegExp As RegExp
       Dim objMatch As Match
       Dim colMatches   As MatchCollection
       Dim RetStr As String
    
       ' Create a regular expression object.
       Set objRegExp = New RegExp
    
       'Set the pattern by using the Pattern property.
       objRegExp.Pattern = myPattern
    
       ' Set Case Insensitivity.
       objRegExp.IgnoreCase = True
    
       'Set global applicability.
       objRegExp.Global = True
    
       'Test whether the String can be compared.
       If (objRegExp.Test(myString) = True) Then
    
       'Get the matches.
        Set colMatches = objRegExp.Execute(myString)   ' Execute search.
    
        For Each objMatch In colMatches   ' Iterate Matches collection.
          RetStr = RetStr & "Match found at position "
          RetStr = RetStr & objMatch.FirstIndex & ". Match Value is '"
          RetStr = RetStr & objMatch.Value & "'." & vbCrLf
        Next
       Else
        RetStr = "String Matching Failed"
       End If
       TestRegExp = RetStr
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some software written in VB.NET that performs a lot of calculations, mostly
I really really want to write a GreaseMonkey extension. I have written a lot
I have written an application that is used company wide. A lot of users
We have written a data store / grid widget system in JavaScript that automatically
I have written some javascript that I would to encapsulate in a closure so
Well, I have a lot of variables in javascript that I need get the
We have a lot of integration tests written using JUnit 3 , though we're
DirectDraw 7 is very old APIs but we have a lot legacy code written
have written this little class, which generates a UUID every time an object of
I have written this code in JavaScript and works perfectly fine when I include

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.