Question

visual basic calling and returing functins Write the code for a function named CalculateBonus. The function...

visual basic calling and returing functins

Write the code for a function named CalculateBonus. The function receives two decimal variables representing the salary and bonus rate. The function should calculate the bonus amount by multiplying the salary by the bonus rate, and then return the result. Then write the appropriate statement to invoke the function, passing it the decSalary and decRate variables. Assign the function’s return value to the decBonus variable.

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

Code:

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim decSalary As Decimal = 10000
        Dim decRate As Decimal = 15
        Dim decBonus As Decimal

        decBonus = CalculateBonus(decSalary, decRate)

        MessageBox.Show(decBonus)
    End Sub

    Public Function CalculateBonus(ByVal Salary As Decimal, ByVal BonusRate As Decimal) As Decimal
        Return Salary * BonusRate / 100

    End Function
End Class

Output:

1500 OK

Visual Studios Code view:

Form1.vb XForm1.vb [Design] lig (General) Bl (Declarations) 2 references Public Class Form1 E Private Sub Form1_Load (sender

Add a comment
Know the answer?
Add Answer to:
visual basic calling and returing functins Write the code for a function named CalculateBonus. The 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
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