would it be possible to calc formulas such like this one:
v^2 = v0^2 + 2a (x-x0)
in vb!?
I would like to give the V, D0, X and X0 and the program would show me the value of "a"?:sick: :ehh: :eek2:
Printable View
would it be possible to calc formulas such like this one:
v^2 = v0^2 + 2a (x-x0)
in vb!?
I would like to give the V, D0, X and X0 and the program would show me the value of "a"?:sick: :ehh: :eek2:
you may want to put this in the MATH forum. You need to compute the value of A, and the equation computes nothing, as you can't assign a value to v^2. What you have would be v=SQR(rest of equation) to calculate the value of V.
Go to Project|References and add a reference to Microsoft Script Control 1.0. Then
VB Code:
Dim objMSC As New MSScriptControl.ScriptControl objMSC.Language = "vbscript" MsgBox objMSC.Eval("v^2 = v0^2 + 2a (x-x0)")
that will show what?
The value of the equation after substituting values for the variables.
Or you can solve for 'a', then fill the values:
VB Code:
'first dim your variables. use the correct type: 'dim these: v,vo,x,xo msgbox (v^2-vo^2)/(2 * (x-xo))
I get an error:Quote:
Originally posted by MartinLiss
Go to Project|References and add a reference to Microsoft Script Control 1.0. Then
VB Code:
Dim objMSC As New MSScriptControl.ScriptControl objMSC.Language = "vbscript" MsgBox objMSC.Eval("v^2 = v0^2 + 2a (x-x0)")
Syntax error on the equation line
my code:
VB Code:
Dim v As Double Dim v0 As Double Dim a As Double Dim x As Double Dim x0 As Double v = 1 v0 = 2 x = 0 x0 = 3 Dim objMSC As New MSScriptControl.ScriptControl objMSC.Language = "vbscript" MsgBox objMSC.Eval("v^2 = v0^2 + 2a (x-x0)") ' also "v^2 = v0^2 + 2*a (x-x0)" isn't working ---> type mismatch 'a' ' when i use: 'MsgBox objMSC.Eval("v^2 = v0^2 + 2*a * (x-x0)") 'the message is TRUE :ehh:
Seems that this doesn't like much the '='
It solves very well a simple expression :)
I get a complie error. UDT not defined. MS Scripting Control.ocx is referenced, too.
Read my post. Anyways, MSScript can't solve for equations. Either you make your own solver or you solve it yourself for the variable then implement it as a formula.
I got an error trying to create a new instance of ScriptControl. It never even got as far as the messagebox.
you are using this exact code?:Quote:
Originally posted by dglienna
I got an error trying to create a new instance of ScriptControl. It never even got as far as the messagebox.
Dim objMSC As New MSScriptControl.ScriptControl
objMSC.Language = "vbscript"
MsgBox objMSC.Eval("v^2 = v0^2 + 2a (x-x0)")
when you do: Dim objMSC As New
and hit space, does MSScriptControl show up in the list?
nope. Form1, Global, and Project are among what is there...
but it is present in \system32 ?
it's in the project, and I've tried it with and without putting the control on my form1.
thanks BuggyProgrammer now i understand, first i have to simplify the equation in orther to get a=........ then it will do the job :)
thx for te nice help!:afrog:
Any help for me using MSSCRIPT.ocx?
Sorry for responding so late :)Quote:
Originally posted by dglienna
nope. Form1, Global, and Project are among what is there...
but it is present in \system32 ?
it's in the project, and I've tried it with and without putting the control on my form1.
Are you checking it in the references or the tool box? It appears that you have added it as a control (which still works, just not creating it like a class).
If you loaded it like a control, it will work like the code, except you need to place the control on the form:
MSScriptControl1.Language="VBScript"
MSScriptcontrol1.exec "msgbox ""hi"""