Use the same code given just complete it please using Visual basic Subroutines a
ID: 3742572 • Letter: U
Question
Use the same code given just complete it please using Visual basic Subroutines are similar to functions, except they don't return one specific value. This subroutine will ask the user for input, manipulate it, and display the bottom hole pressure. Use the following to complete your code: f. Sub TestBHP ) (Not all code here you will need to write variable declarations and a few lines of input) SurfPressure-cDbl (InputBox ("What is the Wellhead Pressure (psi)? ")) Sg-CDbl (InputBox ("What is the gas specific gravity (-")) GasBHP GasBHP f (SurfPressure, Sg, Depth, AvgTemp) MsgBox("The bottomhole pressure is "& str (GasBHP)&" psi. ") End Sub N.B.: In VBA, the CDbl function converts input into a Double. Run the subroutine by going to Developer, Macros. Choose TestBHP and run it. Use the following test data: Pwh 2000 psi, Zav 1.0, Tav 140F, Sg 0.65, Depth 5000 ft. Snip the resulting dialog box and submit as Figure 2.Explanation / Answer
Sub TestBHP() // subroutines starts
Dim surfPressure As Double // varaible declaration
surfPressure = CDbl(InputBox("What is the Wellhead Pressure (psi)?"))" //user input surfPressure
Dim sg As Double
sg = CDbl(InputBox("What is the Gas Specific gravity (-)?"))"
Dim depth As Double
depth = CDbl(InputBox("What is the Depth (ft)?"))"
Dim avgTemp As Double
avgTemp = CDbl(InputBox("What is the Average Temperature (F)?"))"
Dim gasBHP As Double
gasBHP = GasBHP_f(surfPressure, sg, depth, avgTemp)
MsgBox "Gas Pressure is " & gasBHP // resulting message box
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.