VBScript Help Please

sean82007

Baseband Member
Messages
87
okay Im only 15 and just started learning Vbs off of a tutorial online and have physical science in school. I am trying to make a program that finds the force of something. can u help me this is the code.

Sub Force()
Dim Mass, Accel, Force
Mass = InputBox("Please give the mass of the object.")
Accel = InputBox("Please give the acceleration of the object.")
Force = Mass * Accel
MsgBox "The force of the object is " & Force & "."
End Sub

When i open up the program it doesn't do anything
 
i think you have to call sub Force()
something like this maybe:
Private Sub Form_Load()

Force()

End Sub

sorry i'm not sure if the syntax is right, i haven't really used visual basic much. i hope that helps though

lol i'm 15 also
 
Are you learning VB.NET or VB 6.0? I first learned VB.NET this year and havent learned 6.0.

For VB.NET the code would be....

Dim mass, accel, force As Double
Private Sub Button1_Click...
mass = TextBox1.Text
accel = TextBox2.Text
force = mass * accel
TextBox3.Text = "The force of the object is " & force & "."
End Sub
 
the asumption was that when you wrote vbs people assumed you were using visual basic, as apposed to vb script.

the first answer was correct however,

the sub is not processeduntill it is called, so you have two choices...
either
Code:
Dim Mass, Accel, Force
Mass = InputBox("Please give the mass of the object.")
Accel = InputBox("Please give the acceleration of the object.")
Force = Mass * Accel
MsgBox "The force of the object is " & Force & "."
or
Code:
Force()
Sub Force()
Dim Mass, Accel, Force
Mass = InputBox("Please give the mass of the object.")
Accel = InputBox("Please give the acceleration of the object.")
Force = Mass * Accel
MsgBox "The force of the object is " & Force & "."
End Sub
 
any one with windows can use VBscript... (you don't have to have Visual basic).

create a new file called test.vbs fill it with script (use the example above).
then just double click to run it.
 
Back
Top Bottom