Results 1 to 11 of 11

Thread: How VB6 use some function from .js (javascript)

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Unhappy How VB6 use some function from .js (javascript)

    Hi, I'm new in this forum

    I'm doing some project. I receive data from microcontroller to Activex (write in VB6 and embed in IE). It's can store data already. now I need to send data to Moodle (LMS) with SCORM Standard. I must use some function from .js (like LMSInitialize() ). How VB6 use some function from javascript? May someone advice me? i.e.

    Click button --> use LMSInitialize()

    Thank you.
    Sorry, I'm not good in English

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: How VB6 use some function from .js (javascript)

    Welcome to the forums.

    VB doesn't use java script functions, and javascript doesn't use VB functions.

    They each use their own.

    Why are you mixing and matching the two languages (or trying to anyway)?

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Re: How VB6 use some function from .js (javascript)

    Thank you Hack. May you advice me?
    How to share data in variable between VB6 and Javascript
    Can I send data that I store in VB6 pass to Javascript's Variable? by use ajax , write to XML (and pull by javascript) ......

    anyone have some code please.

    Thank you very much

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How VB6 use some function from .js (javascript)

    You want to click a button in a VB application and then execute a Java script function that is on a webpage? You want to take some data in VB and pass that data to the Java script. Do you want also to have VB get data from a Java script?

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Re: How VB6 use some function from .js (javascript)

    1+2 jmsrickland. I want to have javascript get data from VB when I click a button in ActiveX then passing variable to store in javascript

    Quote Originally Posted by jmsrickland
    You want to click a button in a VB application and then execute a Java script function that is on a webpage? You want to take some data in VB and pass that data to the Java script. Do you want also to have VB get data from a Java script?

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How VB6 use some function from .js (javascript)

    Well I don't know about your ActiveX but below is one way to pass a value from a VB application to a JavaScript. If this isn't exactly what you need maybe you can take it from here and apply it to your particular needs.

    Below is sample HTML source code with JavaScript function
    Code:
    <html>
    <body>
    <form>
    
    <script language="javascript">
    function my_javascript_function(arg1)
    {
      alert("Value from VB Application = " + arg1);
    }
    </script>
    
    </form>
    </body>
    </html>
    Below is simple VB code to pass value to JavaScript function. Use a WebBrowser Control on your Form for this same to work.
    Code:
    Private Sub Command1_Click()
     WebBrowser1.Navigate App.Path & "\JavaScript.html"
    End Sub
    
    Private Sub Command2_Click()
     WebBrowser1.Document.parentWindow.execScript ("my_javascript_function('Hello from VB Application');"), "JScript"
    End Sub

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Re: How VB6 use some function from .js (javascript)

    Thank you. I'm try your code and have problem with Microsoft Internet Control (File not found: 'C:\WINDOWS\system32\ieframe.dll\1) I'm using IE7 VB6 crash after run the code. (I'm looking around forum for solve a problem) anyway if you advice please

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How VB6 use some function from .js (javascript)

    Use IE6, not IE7

  9. #9

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Re: How VB6 use some function from .js (javascript)

    It's work great. Thank you jmsricklan. in

    vb Code:
    1. Private Sub Command2_Click()
    2.  WebBrowser1.Document.parentWindow.execScript ("my_javascript_function('Hello from VB Application');"), "JScript"
    3. End Sub

    If I need to replace 'Hello from VB Application' with <table><tr><td>some variable from texbox</td></tr></table>

    How to write a code?

  10. #10
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: How VB6 use some function from .js (javascript)

    Quote Originally Posted by narudol
    It's work great. Thank you jmsricklan. in

    vb Code:
    1. Private Sub Command2_Click()
    2.  WebBrowser1.Document.parentWindow.execScript ("my_javascript_function('Hello from VB Application');"), "JScript"
    3. End Sub

    If I need to replace 'Hello from VB Application' with <table><tr><td>some variable from texbox</td></tr></table>

    How to write a code?

    Without testing it I would say you can do this:
    Code:
    Private Sub Command2_Click()
     Dim OutputString As String
     
     OutputString = "my_javascript_function(" & "'<table><tr><td>" & Text1.Text & "</td></tr></table>'" & ");"
     
     WebBrowser1.Document.parentWindow.execScript (OutputString), "JScript"
    End Sub

  11. #11

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    6

    Re: How VB6 use some function from .js (javascript)

    I'm working with SCORM and Management system (moodle). now my activex (vb) can embed in html already. But WebBrowser Control open a target html form inside the box. It's can't communicate with moodle. Can I embed activex and form in same html file and passing variable from activex direct to form in same page? i.e. I click and browser can record a String somewhere now put it in html form. Thank You.

    P.S. in Moodle's SCORM Module We can't direct access to html file directly. html file must play by Moodle's SCORM Reader. SCORM Package is Server side file but My Activex is Client Side. I can't send variable to html file that i don't know a URL
    Last edited by narudol; Dec 21st, 2008 at 09:00 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width