Avatar of chantalcookware
chantalcookware
 asked on

Water Rocket Project in Excel Visual Basic

I have a water powered rocket project for my college engineering class, and I have to write a program in Visual Basic in Excel that proves several physics equations about the trajectory of the rocket.

There are 3 phases to the program, but if I could just get one, I believe I could figure out the rest.

I've attached the information in a Word Document.

Thank you!
VBA-Program-of-Water-Rocket.docx
Microsoft ExcelVisual Basic Classic

Avatar of undefined
Last Comment
GrahamSkan

8/22/2022 - Mon
GrahamSkan

Are you the lecturer? It is against the policy of this forum to do students' homework for them.

You have submitted a thirty page explanation of the mathematics involved in this project, but it isn't clear where you are having difficulty. Is it just a matter of converting the equations to code?

I suggest that you put the initial values in a cells of a spreadsheet.

Start at or near the end of the calculation. You will see that the values on the right-hand side need to be determined, so go back and insert the calculation for those values.

In this example I started with acceleration, and saw that we need to find the force and mass of the object, so two more lines have been inserted. But these two lines in turn have right-hand variable that need to be calculated and so on.
Option Explicit

Sub Rocket()
'Declare variables
    Dim sh As Worksheet
    Dim hRocket As Double 'Height
    
    Dim vRocket As Double 'Velocity
    
    Dim mWater As Double 'Mass
    Dim mRocket As Double
    Dim mPayload As Double
    Dim mAir As Double
    Dim mTotal As Double
    
    Dim fNet As Double 'Force
    Dim fThrust As Double
    Dim fGravity As Double
    Dim fDrag As Double
    
    Dim aRocket As Double 'Acceleration
    Dim tim As Double 'Time
    
    'Constants
    Const g As Double = 9.81
    
    
    
    'Get initial values
    Set sh = ActiveWorkbook.Sheets(1)
    mRocket = sh.Cells(2, 1).Value
    mWater = sh.Cells(2, 2).Value
    
    'Calculations
    '...
    
    fNet = fThrust - fDrag - fGravity
    mTotal = mWater + mPayload + mRocket + mAir
    
    aRocket = fNet / mTotal

End Sub

Open in new window

chantalcookware

ASKER
I'm the Teaching Assistant for the engineering class and have little background in VBA, but I have more experience with the Physics aspect of the code. I'm looking for help in setting up the loops of the program and the code for the actual excel page where data is inputed into. Thank you
ASKER CERTIFIED SOLUTION
GrahamSkan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
chantalcookware

ASKER
So in order to have all 3 phases as loops, would you set those up with For loops as well?

Sorry I'm very new to VBA!
Your help has saved me hundreds of hours of internet surfing.
fblack61
GrahamSkan

The code is only to give you an idea about how to go about it. It is incomplete and doesn't actually work, so outline code for the other phases would be much the same.

Providing full working code for such a project is beyond the remit of this forum. We are not permitted to solicit business, but some experts can take on this sort of work on a paid basis. Any that do will have contact information in their profiles.