Question

Visual Basic Write the code snippit for the btnCalculate event handler based upon the following pseudo-code...

Visual Basic

Write the code snippit for the btnCalculate event handler based upon the following pseudo-code and User Interface. Don’t forget to create all variables needed and perform all necessary data conversions (ToString,TryParse). Use the control names listed in the pseudo-code. The pseudo-code is as follows

Create variables for item cost (dblCost) and item amount (dblAmount)

Get the item cost from tbxCost and place it in the variable(dblCost)

Gt item amount from tbxAmount and place in it the variable (dblAmount)

If the item amount or item cost is zero

            Display the message “Enter amount and cost” in the label (lblResult)

Else

            Calculate the total cost by multiplying the item cost by the item amount

            Display the total cost in lblResult as currency with two decimal places

Endif

Homework Answers

Answer #1

Code:=

Dim dblCost, dblAmount As Integer
    Dim tcost As Double

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click

        dblCost = Val(tbxCost.Text)
        dblAmount = Val(tbxAmount.Text)
        If dblCost = 0 Or dblAmount = 0 Then
            lblResult.Text = "Enter the Cost and Amount"
        Else
            tcost = dblCost * dblAmount
            lblResult.Text = "Total cost is Rs. " & FormatNumber(tcost, 2)
        End If
    End Sub

    Output:=

Know the answer?
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
Similar Questions
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
Use a few sentences to describe the problem given below . Also, Identify the nouns and...
Use a few sentences to describe the problem given below . Also, Identify the nouns and verbs used in the below project descriptions.  Identified nouns, list the ones that are necessary to define variables in your program. For each variable, specify its name, data type, and what information it is used to store. Write the pseudo code algorithm (i.e. algorithm steps) to solve this problem. (For the base salaries and commission rates use constants instead to keep these values. Use the...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...