Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 10-26-2004, 08:04 PM   #1
Baseband Member
 
sean82007's Avatar
 
Join Date: May 2004
Posts: 87
Default VBScript Help Please

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
__________________

sean82007 is offline   Reply With Quote
Old 10-26-2004, 08:31 PM   #2
Daemon Poster
 
broknhabit's Avatar
 
Join Date: Sep 2004
Posts: 1,222
Send a message via AIM to broknhabit
Default Re: VBScript Help Please

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
__________________

__________________
seriously
broknhabit is offline   Reply With Quote
Old 10-27-2004, 12:47 AM   #3
Daemon Poster
 
CarpeNoctem's Avatar
 
Join Date: Oct 2004
Posts: 1,274
Send a message via AIM to CarpeNoctem Send a message via MSN to CarpeNoctem
Default

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
__________________
How many people can read hex if only you and dead people can read hex?

Start using reputation points!!!
CarpeNoctem is offline   Reply With Quote
Old 10-27-2004, 08:01 AM   #4
Baseband Member
 
sean82007's Avatar
 
Join Date: May 2004
Posts: 87
Default Re: VBScript Help Please

Nah Sorry guys that didn't work. Im not using any special program for it just notepad.
sean82007 is offline   Reply With Quote
Old 10-27-2004, 03:04 PM   #5
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,007
Default Re: VBScript Help Please

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
root is offline   Reply With Quote
Old 10-27-2004, 08:31 PM   #6
Daemon Poster
 
CarpeNoctem's Avatar
 
Join Date: Oct 2004
Posts: 1,274
Send a message via AIM to CarpeNoctem Send a message via MSN to CarpeNoctem
Default

Oh snap, my bad.
__________________
How many people can read hex if only you and dead people can read hex?

Start using reputation points!!!
CarpeNoctem is offline   Reply With Quote
Old 10-28-2004, 07:49 AM   #7
Baseband Member
 
sean82007's Avatar
 
Join Date: May 2004
Posts: 87
Default cool

Sweet thanx dude it worked. So like everytime i have to call the sub.
sean82007 is offline   Reply With Quote
Old 10-28-2004, 09:43 AM   #8
Daemon Poster
 
soccerfan's Avatar
 
Join Date: Aug 2004
Posts: 581
Send a message via MSN to soccerfan
Default Re: VBScript Help Please

not verygood a vb because i dont have vb
soccerfan is offline   Reply With Quote
Old 10-28-2004, 01:51 PM   #9
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,007
Default Re: VBScript Help Please

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.
root is offline   Reply With Quote
Old 11-01-2004, 07:50 AM   #10
Baseband Member
 
sean82007's Avatar
 
Join Date: May 2004
Posts: 87
Default Re: VBScript Help Please

thats why im using VBScript cause u dont need no program for it
__________________

sean82007 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 12:02 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0