Question

Create and call a function Using the Visual Basic Editor: create a VBA procedure named call_function...

  1. Create and call a function
  1. Using the Visual Basic Editor:
    1. create a VBA procedure named call_function that does the following:
      1. Prompts the user, using two input boxes, for the height and the radius of the base of a cone.
      2. Calls a function named cone_volume and passes the two values to it.
      3. Receives a value back from the function and displays it in a message to the user.
    2. Create a function named cone_volume that does the following:
      1. Receives the two values from the procedure.
      2. Calculates the volume of the cone.
      3. Returns the value to the procedure.

The volume of a cone is:     V = 1/3 × pi × r2 × h

V = volume

pi = 3.14159265358979

r = radius of the base

r = height

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the VBA code that will calculate the volume of a cone using function.

VBA Code-

Sub call_function()
Dim height As Double 'Declaring variable
Dim radious As Double
Dim volume As Double
height = InputBox("Enter height") 'Getting user input
radious = InputBox("Enter radious")
volume = cone_volume(height, radious) 'Calling function cone_volume by passing parameter
MsgBox ("Volume is: " & volume) 'Displaying the result
End Sub
Function cone_volume(h As Double, r As Double) 'Function definition
Dim vol As Double 'Declaring variable to store volume
vol = 1 / 3 * 3.14 * r * r * h 'Calculating volume
cone_volume = vol 'Returning result
End Function

Code Screenshot-

Output-

Add a comment
Know the answer?
Add Answer to:
Create and call a function Using the Visual Basic Editor: create a VBA procedure named call_function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MESSAGE 1 1. Using the Visual Basic Editor, create a VBA procedure named message_1 that does...

    MESSAGE 1 1. Using the Visual Basic Editor, create a VBA procedure named message_1 that does the following: a. Asks the user for their name (using an Input Box). b. Determines the number of slides in the presentation using the appropriate code. c. Displays a message back to the user (using a Message Box) that contains the name entered and the number of slide in the presentation. The message should be something like this: (Hello Sally, there are 8 slides...

  • Using powerpoint VBA, Using the Visual Basic Editor, create a VBA procedure named message_2 that does...

    Using powerpoint VBA, Using the Visual Basic Editor, create a VBA procedure named message_2 that does the following:Create a Message Box that meets the following requirements: A Multiline Message Box with the following message: Welcome to PowerPoint! Do you wish to run this Presentation? Contains a Yes and a No button. Contains a Question Mark icon. The No button is the default button. The Message Box title reads "Run Show?". If the user clicks the Yes button, the slide show...

  • create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates...

    create C program that: Has a triangle function (which receives and sends no arguments) to: Calculates the area of ANY* triangle (prompts the user for necessary values.) Uses integer values and displays them in a field width of 8. Provides an answer to the user such as follows: The area of the triangle with base 7 and height 8 is 28. Has a circle function (which receives and sends no arguments) to: Prompts the user for necessary values. Accurately calculate...

  • 1 CREATE A DOCUMENT (USE CHAPTER 20 FOR REFERENCE) 1. Using the Visual Basic Editor, create...

    1 CREATE A DOCUMENT (USE CHAPTER 20 FOR REFERENCE) 1. Using the Visual Basic Editor, create a VBA procedure named doc_create that does the following: a. Creates a new Word document. b. Adds 1 line of text that says “This is my document!” c. Saves the file as myFile.docx d. Closes the document.

  • Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base...

    Use Visual Basic language The function, FindAreaOfTriangle, calculates the area of a triangle given the base and height. Write code that calls the function with: Base = 8; Height = 16.3 and returns the answer to dblAreaOfTriangle.     Function FindAreaOfTriangle(dblBase As Double, dblHeight As Double) As Double         Dim dblArea As Double         dblArea = (dblBase * dblHeight) / 2         Return dblArea     End Function Display keyboard shortcuts for Rich Content Editor

  • this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees...

    this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees that returns 1 if an array has three consecutive values of 3 somewhere in the array. Otherwise, return 0. The procedure’s input parameter list contains a pointer to the array and the array’s size. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. Write a test program that calls FindThrees...

  • Code should be written in C++ 2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console a...

    Code should be written in C++ 2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console application that prompts the user with a menu and various options. Starting from Lab03, prompt the user for a char value that corresponds to one of the following menu options: a. Sphere=4*pi"radius3 (hint: use a constant value for pi=3.1415) b. Right Circular Cylinder- piradius*height c. Rectangular Parallelepiped length *width height d. Cone-*pi*radius2 height 3 x. Exit menu. Implement...

  • PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use...

    PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use the following names for the project and solution, respectively: Chopkins Project and Chopkins Solution. Save the application in the VB2017\Chap03 folder. Change the form file's name to Main Form.vb. Change the form's name to frmMain. Create the interface shown in Figure 3-37. The interface contains six labels, three text boxes, and two buttons. The application calculates and displays the total number of packs ordered...

  • This is for Pycharm a python course. Can I get some help doing this and understand...

    This is for Pycharm a python course. Can I get some help doing this and understand it? ⑤ : ib tps://canvas.pasadena.edu/courses/1032754/assi a ☆ 西%N m Crowfall. Th O computing, with-c- O PHP Tutorial | SoloL ontoja. on tojav.. Write functions . def main) . def sphereVolume(r) . def sphereSurfacelr) def cylinderVolumetr. h) . def cylinderSurface(r, h) . def coneVolumefr, h) . def coneSurface(r, h) ences rations main() # call amin function at teh end In the main display, a menu...

  • Write a C++ program to compute the total volume of N cones, where N is a...

    Write a C++ program to compute the total volume of N cones, where N is a number entered by the user. Repeat the request for N until the user enters a positive number. For each cone, ask for the radius and height, compute the volume, and add that volume to the total. Each time you ask the user to enter either the height or the radius, if the user does not enter a positive number, display an error message and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT