Question

In: Computer Science

EXCEL VBA ABC company gives discount as follows: Purchase > $400                                

EXCEL VBA

  1. ABC company gives discount as follows:
    Purchase > $400                                                                     Discount rate = 5%
    Purchase between $300 and $400                                          Discount rate = 4%
    Purchase >= $100 and < $300                                              Discount rate = 2%
    Purchase < 100                                                                       No discount
    Purchase = Price * Quantity
    Discount = Purchase * Discount rate                                    
    Net Purchase = Purchase – Discount

Total Net Purchase is the running total of Net Purchases

Create a user interface form as shown below. Use text boxes to input price and quantity. Use labels to display the discount, net purchase (purchase amount after discount) and total net purchases. Click calculate button to calculate and display discount, net purchase, and total net purchases; click clear button to clear values from the text boxes and labels, except total net purchases; send the focus to the price text box.
Click exit button to end the application.

  1. Create a sub procedure in a module to calculate:
    a) the sum of even integers from 4 to 12 using DO WHILE. Display the sum in the message box. Name the sub procedure as Q2a.
    b) the sum of odd integers from 5 to 9 using FOR NEXT. Display the sum in message box. Name the sub procedure as Q2b.
  2. Create a sub procedure named as Question3 in a module to calculate the value and total value of items using a Do/while Loop. Value = Price * Quantity. Total value is the running total of values. Use INPUTBOX function to get the price and quantity. Display the value in the message box. Display total value in the message box after exiting the loop. Loop is entered by inputting “Y” at the prompt “Do you wish to continue?” and exited by entering “N” at the prompt “Do you wish to continue?”
  3. Create a sub procedure named as Question4 in a module to find the capital. Use INPUTBOX function to get the state and message box function to display the capital.

State                Capital

MN                   St.Paul

WI                   Madison

TX                   Austin

Solutions

Expert Solution

Answer: Hey dear student find the solution of your query, if you have any doubt feel free to ask. Thanks!!

1- UserForm at the running time

Code to copy:

Private Sub CommandButton1_Click() 'commamdButton click event
Dim purchase As Double 'variable to store price
purchase = TextBox1.Value * TextBox2.Value 'calculate total purchase
If (purchase > 400) Then 'calculate discount creteria purchase
TextBox3.Value = purchase * 5 / 100 'discount display in textbox3
Else
If (purchase >= 300 And purchase <= 400) Then
TextBox3.Value = purchase * 4 / 100
Else
If (purchase >= 100 And purchase <= 300) Then
TextBox3.Value = purchase * 2 / 100
Else
If (purchase < 100) Then
TextBox3.Text = "No discount"
End If
End If
End If
End If
purchase = purchase - TextBox3.Value 'calculate net purchase
TextBox4.Value = price
End Sub

Private Sub CommandButton2_Click() 'exit button
UserForm1.Hide
End Sub

Private Sub CommandButton3_Click() 'clear button
TextBox1.Text = Clear
TextBox2.Text = Clear
TextBox3.Text = Clear
TextBox4.Text = Clear
End Sub

a - Procedure to add even integers:

Code to Copy:

Public Sub Q2a() 'procedure to add 4 to 12
Dim sum, i As Integer 'variables
sum = 0
i = 4
Do While (i < 13) 'do while loop to sum up integers
If (i Mod 2 = 0) Then
sum = sum + i
End If
i = i + 1
Loop
MsgBox ("Sum of even integers: " & sum) ''print sum on the msgbox
End Sub

b- Procedure Q2b:

Code to copy:

Public Sub Q2b() 'procedure to add 5 to 9 odd integers
Dim sum, i As Integer 'variables
sum = 0
For i = 5 To 9 'for nextloop to sum up integers
If (i Mod 2 <> 0) Then
sum = sum + i
End If
Next i
MsgBox ("Sum of odd integers: " & sum) ''print sum on the msgbox
End Sub

Procedure Question3:

Code to Copy:

Public Sub Question3() 'procedure to enter price and quantity
Dim price, q As Double 'variables

ans = "Y"
Do While (ans = "Y")
price = InputBox("Enter price for item") 'takes input from user
q = InputBox("Enter Quantity")
ans = InputBox("Do you want to continue?")
MsgBox ("Total price: " & price * q) ''print total price on the msgbox
Loop

End Sub


Related Solutions

ABC gives XYZ, Inc. a two-year, $1,000 note to ABC, Inc. to cover purchase of goods...
ABC gives XYZ, Inc. a two-year, $1,000 note to ABC, Inc. to cover purchase of goods and services on 1/1/2017. The stated interest rate is 5% and the market rate for similar notes is 6%. Interest is payable semi-annually. Since the market rate is known, use it to value the note receivable.
In VBA, write a code that does as follows: The first worksheet ("Ex. 1") has a...
In VBA, write a code that does as follows: The first worksheet ("Ex. 1") has a list of 50 numbers. Write a program that will read them into an array, then will calculate and output the following: - How many of the numbers are even (output in E2) - How many of the numbers are greater than 300 (output in E3) - The average of the numbers (output in E4) - In column B, output next to each number, the...
(EXCEL vba) Problem: Trying to remove the entire row if the year is before 2019. Current...
(EXCEL vba) Problem: Trying to remove the entire row if the year is before 2019. Current code: Range("B2").Select Do Until ActiveCell.Value = "" If ActiveCell.Value < 2019 Then ActiveCell.EntireRow.Delete Else ActiveCell.Offset(1, 0).Select End If Loop Code Problem: My data sets can be 1000's of rows so checking every cell is very slow. Since the data is always in order, all I need to do is find the first entry <2019 and then select xlDown and delete everything, but I don't...
Excel to VBA Please post with screen shots Add a few Check Box controls or Option...
Excel to VBA Please post with screen shots Add a few Check Box controls or Option Button controls to a worksheet and then use a Select/Case code structure in a sub procedure that outputs a message to the user telling him which box or option has been selected.
use Excel : The Mann company belongs to a risk class for which the appropriate discount...
use Excel : The Mann company belongs to a risk class for which the appropriate discount rate is 10%. The company currently has 260,000 outstanding shares selling at $107 each. The firm is contemplating the declaration of a $4 dividend at the end of the fiscal year that just began. Assume there are no taxes on dividends. Answer the following questions based on the Miller and Modigliani model, which is discussed in the text. A. What will be the price...
The company ABC Inc . is having three shareholders as follows: - A = owner of...
The company ABC Inc . is having three shareholders as follows: - A = owner of 30 ordinary shares, containing the right to participate to the remaining property in case of liquidation of the company and the right to vote - B = owner of 35 shares, class A containing the right to receive dividends and the remaining property in case of liquidation of the company - C = owner of 40 shares, class B containing the right to receive...
To please be done in excel: It is November, 2001. ABC Ltd. is a company listed...
To please be done in excel: It is November, 2001. ABC Ltd. is a company listed on the Stock Exchange. The company was founded in the early 1980’s and management identified a market for small photocopier and fax machines and in later years, tablets. The company has in the past relied on importing equipment from the Far East, but the recent decline in the value of the Peso, combined with increased local competition, has resulted in a significant decrease in...
1.ABC company purchase $500 of inventory with cash. how does the equaiton change? 2. Abc company...
1.ABC company purchase $500 of inventory with cash. how does the equaiton change? 2. Abc company purchase $500 of supplies on credit? how does the equation change? 3. you invest $50,000 cash into ABC company. how does the equation change?
A mail order company gives 5% discount on all customer orders with advanced payment sent with...
A mail order company gives 5% discount on all customer orders with advanced payment sent with the order. If a regular customer places an order of $5,000 or more also receives 5% discount. Otherwise no discount given. (A) Write process specification for the mail order using Structured English    (B) To document the decision process for mail order using decision table, List the conditions with condition alternatives    List the Actions to be taken Construct the decision table for this...
Budget Problem Part A The ABC company manufactures bookcases that sell for $400. Budgeted sales for...
Budget Problem Part A The ABC company manufactures bookcases that sell for $400. Budgeted sales for first months are as follows: Month Budgeted Sales (units) January 1000 February 1500 March 2500 April 2000 Required Calculate sales budget in $ for each monthand total the first quarter Part B Each bookcase requires 30 square feetof oak at a cost of $10 per sq foot.. the company wants to maintain an inventory of bookcases equal to 10% of the following month,s sales....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT