How to Access varaibles in JavaScript from Vb.NET

From the Windows Form (frmstart.vb) how can I access the Functions and values of Variables in the JavaScript (Test.js). I need with example code. Is it possible access the things in the JavaScript from Windows Forms. This is a windows application for getting values from JavaScript variables. Both the files are included in Windows application project in VB.NET.

frmStart.vb
============

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intTest as integer
Dim strTest as String

intTest = intTestJS     'Not able to assign the global variables from JavaScript file
    strTest = strTestJS     'Not able to assign the global variables from JavaScript file

End Sub

------------------------------------------------------------------------------------------------------------


Test.js
=======

var intTestJS = 0;
var strTestJS = "Evin";

function TestValue()
{
intTestJS = 222;
}


Answer this question

How to Access varaibles in JavaScript from Vb.NET

  • Jaime Atiles

    Link doesnt work in the above posted article, please re/advise.  I'm looking to exchange objects between vb.net application and a vbscript program.
  • micca46899

    Yes, you can possibly do it BUT only thru COM event. The example can be found at ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/dnmag02/html/UserCtrl.htm
  • net2020

    Is this possible at all  I mean from your UserControl, can you have an onclick event that will trigger a javascript function  we have the same problem i think. If anyone has suggestions please let us know. Thanks.
  • How to Access varaibles in JavaScript from Vb.NET