Community discussion forum
Javascript
-
I just want to know if it is possible to intregrate Javascript in VB. So you use the Javascript code to do functions in a VB program. Is this possible? If so, how? If not, thnx anyway.
-
I don't know much about this thing but this might be helpful to you...
-
No I don't mean that stuff. I mean this:
I want to let a Javascript do the work:
Code: function sim() {
for(var i=0;i<12;i++)
{
if(document.Eingaben.a.value == "")
document.Eingaben.a.value = "0";
};
/* Variablen initialisieren /
var metall = new Array(8);
var kristall = new Array(8);
var deuterium = new Array(8);
var verloren = new Array(8);
var uebrig = new Array(8);
var hull = new Array(8);
var temp;
var t_m = 0, t_c = 0, t_d = 0, t_v = 0, t_k = 0;
var m_cost = new Array(2,1.5,6,20,2,50,10,50);
var c_cost = new Array(0,0.5,2,15,6,50,10,50);
var d_cost = new Array(0,0,0,2,0,30,0,0);
var iraks = parseInt(document.Eingaben.a[10].value);
var araks = parseInt(document.Eingaben.a[8].value);
var pziel = document.Eingaben.priz.selectedIndex;
var z = 8;
if(pziel == 8)
pziel = 7;
hull[0] = hull[1] = 200(1+(parseInt(document.Eingaben.a[9].value)/10));
hull[2] = hull[4] = 800(1+(parseInt(document.Eingaben.a[9].value)/10));
hull[3] = 3500(1+(parseInt(document.Eingaben.a[9].value)/10));
hull[5] = hull[7] = 10000(1+(parseInt(document.Eingaben.a[9].value)/10));
hull[6] = 2000(1+(parseInt(document.Eingaben.a[9].value)/10));
var schaden = (parseInt(document.Eingaben.a[10].value)-parseInt(document.Eingaben.a[8].value))(12000(1+(parseInt(document.Eingaben.a[11].value)/10)));
/* Ergebnis für Abfang- und IP - Raks anzeigen /
if(schaden>=0)
{
if(araks > 0)
{
document.getElementById("v9").innerHTML = "0";
document.getElementById("k9").innerHTML = document.Eingaben.a[8].value;
document.getElementById("m9").innerHTML = document.Eingaben.a[8].value * 8 + " k";
document.getElementById("c9").innerHTML = "0";
document.getElementById("d9").innerHTML = document.Eingaben.a[8].value * 2 + " k";
} else
{
document.getElementById("v9").innerHTML = "-";
document.getElementById("k9").innerHTML = "-";
document.getElementById("m9").innerHTML = "-";
document.getElementById("c9").innerHTML = "-";
document.getElementById("d9").innerHTML = "-";
}
} else
{
document.getElementById("v9").innerHTML = araks-iraks;
document.getElementById("k9").innerHTML = iraks;
document.getElementById("m9").innerHTML = iraks * 8 + " k";
document.getElementById("c9").innerHTML = "0";
document.getElementById("d9").innerHTML = iraks * 2 + " k";
}
if(iraks > 0)
{
document.getElementById("v10").innerHTML = "0";
document.getElementById("k10").innerHTML = iraks;
document.getElementById("m10").innerHTML = iraks * 25 + " k";
document.getElementById("c10").innerHTML = iraks * 5 + " k";
document.getElementById("d10").innerHTML = iraks * 20 + " k";
} else
{
document.getElementById("v10").innerHTML = "-";
document.getElementById("k10").innerHTML = "-";
document.getElementById("m10").innerHTML = "-";
document.getElementById("c10").innerHTML = "-";
document.getElementById("d10").innerHTML = "-";
}
/ Schadensberechnung /
if(document.Eingaben.priz.selectedIndex == 8)
{
z = 5;
for(i=7;i>5;i--)
{
if(parseInt(document.Eingaben.a.value) > 0)
{
temp = Math.floor((schaden / hull));
if(document.Eingaben.a.value < temp)
temp -= (temp - parseInt(document.Eingaben.a.value));
document.getElementById("v"+i).innerHTML = parseInt(document.Eingaben.a.value) - temp;
document.getElementById("k"+i).innerHTML = temp;
document.getElementById("m"+i).innerHTML = m_cost * temp + " k";
document.getElementById("c"+i).innerHTML = c_cost * temp + " k";
document.getElementById("d"+i).innerHTML = d_cost * temp + " k";
schaden -= temp * hull;
t_v += parseInt(document.Eingaben.a.value) - temp;
t_k += temp;
t_m += temp * m_cost;
t_c += temp * c_cost;
t_d += temp * d_cost;
} else
{
document.getElementById("v"+i).innerHTML = "-";
document.getElementById("k"+i).innerHTML = "-";
document.getElementById("m"+i).innerHTML = "-";
document.getElementById("c"+i).innerHTML = "-";
document.getElementById("d"+i).innerHTML = "-";
}
};
}
if(parseInt(document.Eingaben.a[pziel].value) > 0)
{
temp = Math.floor((schaden / hull[pziel]));
if(document.Eingaben.a[pziel].value < temp)
temp -= (temp - parseInt(document.Eingaben.a[pziel].value));
document.getElementById("v"+pziel).innerHTML = parseInt(document.Eingaben.a[pziel].value) - temp;
document.getElementById("k"+pziel).innerHTML = temp;
document.getElementById("m"+pziel).innerHTML = m_cost[pziel] * temp + " k";
document.getElementById("c"+pziel).innerHTML = c_cost[pziel] * temp + " k";
document.getElementById("d"+pziel).innerHTML = d_cost[pziel] * temp + " k";
schaden -= temp * hull[pziel];
t_v += parseInt(document.Eingaben.a[pziel].value) - temp;
t_k += temp;
t_m += temp * m_cost[pziel];
t_c += temp * c_cost[pziel];
t_d += temp * d_cost[pziel];
} else
{
document.getElementById("v"+pziel).innerHTML = "-";
document.getElementById("k"+pziel).innerHTML = "-";
document.getElementById("m"+pziel).innerHTML = "-";
document.getElementById("c"+pziel).innerHTML = "-";
document.getElementById("d"+pziel).innerHTML = "-";
}
for(i=0;i<z;i++)
{
if(i != pziel)
{
if(parseInt(document.Eingaben.a.value) > 0)
{
temp = Math.floor((schaden / hull));
if(document.Eingaben.a.value < temp)
temp -= (temp - parseInt(document.Eingaben.a.value));
document.getElementById("v"+i).innerHTML = parseInt(document.Eingaben.a.value) - temp;
document.getElementById("k"+i).innerHTML = temp;
document.getElementById("m"+i).innerHTML = m_cost * temp + " k";
document.getElementById("c"+i).innerHTML = c_cost * temp + " k";
document.getElementById("d"+i).innerHTML = d_cost * temp + " k";
schaden -= temp * hull;
t_v += parseInt(document.Eingaben.a.value) - temp;
t_k += temp;
t_m += temp * m_cost;
t_c += temp * c_cost;
t_d += temp * d_cost;
} else
{
document.getElementById("v"+i).innerHTML = "-";
document.getElementById("k"+i).innerHTML = "-";
document.getElementById("m"+i).innerHTML = "-";
document.getElementById("c"+i).innerHTML = "-";
document.getElementById("d"+i).innerHTML = "-";
}
}
};
document.getElementById("v8").innerHTML = t_v;
document.getElementById("k8").innerHTML = t_k;
document.getElementById("m8").innerHTML = t_m + " k";
document.getElementById("c8").innerHTML = t_c + " k";
document.getElementById("d8").innerHTML = t_d + " k";
};
function sim2() {
for(var i=0;i<12;i++)
{
if(document.Eingaben.a.value == "")
document.Eingaben.a.value = "0";
};
var schaden = 12000 * (1+(parseInt(document.Eingaben.a[11].value)/10));
var noetig = ((parseInt(document.Eingaben.a[0].value)+parseInt(document.Eingaben.a[1].value))200 + (parseInt(document.Eingaben.a[2].value)+parseInt(document.Eingaben.a[4].value))800 + parseInt(document.Eingaben.a[3].value)3500 + (parseInt(document.Eingaben.a[5].value)+parseInt(document.Eingaben.a[7].value))10000 + parseInt(document.Eingaben.a[6].value)2000)(1+(parseInt(document.Eingaben.a[9].value)/10));
var req = Math.floor(noetig/schaden+0.99999999999999) + parseInt(document.Eingaben.a[8].value);
alert("missiles required : " + req + " ( " + req25000 + " metal, " + req5000 + " crystal, " + req20000 + " deuterium )");
};
function lesen() {
var text = document.Eingaben.Bericht.value;
if(text.indexOf('Verteidigung') != -1) {
var Pos1 = text.indexOf('Missile Launcher');
var Pos2 = text.indexOf('Small Laser');
var Pos3 = text.indexOf('Heavy Laser');
var Pos4 = text.indexOf('Ion Cannon');
var Pos5 = text.indexOf('Gauss Cannon');
var Pos6 = text.indexOf('Plasma Cannon');
var Pos9 = text.indexOf('Anti-ballistic Missile');
var a = parseInt(text.substring(Pos1 + 13,Pos1 + 20));
var b = parseInt(text.substring(Pos2 + 23,Pos2 + 30));
var c = parseInt(text.substring(Pos3 + 23,Pos3 + 30));
var d = parseInt(text.substring(Pos4 + 14,Pos4 + 24));
var e = parseInt(text.substring(Pos5 + 10,Pos5 + 20));
var f = parseInt(text.substring(Pos6 + 12,Pos6 + 22));
var g = parseInt(text.substring(Pos9 + 13,Pos9 + 20));
if(Pos1 == -1)
a = 0;
if(Pos2 == -1)
b = 0;
if(Pos3 == -1)
c = 0;
if(Pos4 == -1)
d = 0;
if(Pos5 == -1)
e = 0;
if(Pos6 == -1)
f = 0;
if(Pos9 == -1)
g = 0;
document.Eingaben.a[0].value = a;
document.Eingaben.a[1].value = b;
document.Eingaben.a[2].value = c;
document.Eingaben.a[4].value = d;
document.Eingaben.a[3].value = e;
document.Eingaben.a[5].value = f;
document.Eingaben.a[8].value = g;
if(text.indexOf('Small Shield Dome') != -1)
document.Eingaben.a[6].value = "1";
else
document.Eingaben.a[6].value = "0";
if(text.indexOf('Large Shield Dome') != -1)
document.Eingaben.a[7].value = "1";
else
document.Eingaben.a[7].value = "0";
if(text.indexOf('Armor Technology') != -1) {
Pos10 = text.indexOf('Armor Technology');
document.Eingaben.a[9].value = parseInt(text.substring(Pos10 + 20,Pos10 + 27));
}
} else
alert("scan report is incomplete!");
}
So that I intregrate that script part in my program. Is this possible? -
sorry i don't know...
can't help you further, coz as i mentioned earlier i don't know much about the topic...
-
Are you looking for a return of the javascript code. to be pushed into VB?
If so then you chould do this with the MS-Script control.
hope that may give you some ideas. -
[1] [/1] Hi ,
I attended an interview today.. The Intervierwer asked me ..
What are the Objects of
ADO
ADO.NET
ASP
ASP.NET
VB
VB.NET
Can u kindly reply me ....
Awaiting for ur Reply at the Earliest
--------------------------------------------------------------------------------
Take Care., Keep in touch
Awaiting for ur Reply at the Earliest
* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *- * - *
N.ShanmugaRaj
Mobile : 91+98650-76565
-
huh
What has that go to do with using JavaScript in VB
-
Make ur own topic will you? And what you said vbdream2k... is not what I meant. I meant that the program can use the javascript code to do a function. But it is not realy nessesary, but it would be kind if someone could answer this
-
I still don't entirely get the context - looking at your code, you're wanting to use JavaScript to interact with a HTML page - but where is this HTML page in your VB program? are you using the web browser control and want to execute code on that?
-
No no, I just want to know if you can use Javascript + VB script to preform an action without a internetpage or something.
Something like this you know:
Private Sub Form_Load ()
Call: javascript
End Sub
<<Here the javascript that is called....>>
So the javascript can preform an action FOR the VB program. -
There's no way for that JavaScript code to have any way of interacting with your VB program... so... no. What exactly are you trying to achieve? (ignoring the fact you want to do it with JAvaScript)
-
I just was curious
Maybe it was possible but it isn't
Thnx all.
Topic closed!
Post a reply
Related discussion
-
How to call javascript from vb
by hugephonebill (0 replies)
-
Visual Basic 6.0 Installation doubt
by flower123 (0 replies)
-
Javascript execution
by dmb_job (2 replies)
-
java
by krish (7 replies)
-
VB.NET: How to convert this code from java to VB
by porkmanii (3 replies)
Related articles
Quick links
Recent activity
- Van Thieu replied to C++ CATMULL-ROM
- Mark Neal replied to Which Blu-ray should i choose?
- emma limei replied to How to Download and Play Yo...
- jump tracy replied to How to transfer or copy so...
- Mark Neal replied to Pavtube Blu-ray Ripper for ...
- tt zhao replied to Which Blu-ray should i choose?
Enter your message below
Sign in or Join us (it's free).