Writing Variable Codes VB 2008

40 pts.
Tags:
Code
VB 2008
I'm not a programmer but, taking my first VB 2008 course and one of the problems is asking me to write a variable code in a TextBox called TitleTextBox and in the box you should be able to write something and have it change. The book is not very helpful and I could use some help.

Software/Hardware used:
Visual Basic 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.

What I’m trying to do is write a program that will take the quantity of books purchased, the title of the book, and the price of the book.
The Quantity is to display as a number (Got that)
The Price is to display as currency but when I write the code it shows currency when I go to debugg it but doesn’t show the value that I typed.
From here I needed to calculate the extended price (Got that)
I have to give a 15% discount and it needs to show the value in the text box but, it’s not.
But the code for Discounted Price shows the discounted amount from the Extended Price.

Can’t get the Price to display as currency showing the $ value only shows $0.00
Can’t get the Discount Text to show the discount amount. It’s just blank

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    The question is not clear. Could you please be more specific, and tell us what exactly you need help with ? Thanks,
    69,835 pointsBadges:
    report
  • carlosdl
    Ok, can you post your code ? So we can take a look and try to help.
    69,835 pointsBadges:
    report
  • MaryErban
    'Project: Chapter Example BookSales 'Date: November 26, 2009 'Programmer: Mary Erban Practice 'Description: This project inputs sales information for books,It calculates the extened price and discount for a sale. Uses variables, constants, and calculations. Note that no erro trapping is included in this version of the program. 'Folder: CH03BookSales Public Class BookSalesForm 'Declare the variables. Dim QuantityInteger, NumberInteger As Integer Dim PriceDecimal, ExtendedPriceDecimal, DiscountDecimal, DiscountedPriceDecimal As Decimal 'Declare a string variable. Dim NameString As String 'Declare integer variables. Dim CounterInteger As Integer Dim MaxInteger As Integer = 100 'Declare the constant. Const DISCOUNT_RATE_Decimal As Decimal = 0.15 Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click 'Print the form. PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview PrintForm1.Print() End Sub Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click 'Calculate the price and discoutn. Dim QuantityInteger As Integer Dim PriceDecimal, ExtendedPriceDecimal, DiscountDecimal, _ DiscountedPriceDecimal As Decimal Try 'Convert quantity to numberica variables. QuantityInteger = Integer.Parse(QuantityTextBox.Text) Try 'Convert price if quantity was successful. PriceDecimal = Decimal.Parse(PriceTextBox.Text) Catch ex As Exception End Try Catch ex As Exception End Try 'Convert input values to numberic variables. QuantityInteger = Integer.Parse(QuantityTextBox.Text) PriceDecimal = Decimal.Parse(PriceTextBox.Text) 'Caluclate values. ExtendedPriceDecimal = QuantityInteger * PriceDecimal DiscountDecimal = Decimal.Round( _ (ExtendedPriceDecimal * DISCOUNT_RATE_Decimal), 2) DiscountedPriceDecimal = ExtendedPriceDecimal - DiscountDecimal 'Fomat and display answers. ExtendedPriceTextBox.Text = ExtendedPriceDecimal.ToString("C") DiscountTextBox.Text = DiscountDecimal.ToString("N") DiscountedPriceTextBox.Text = DiscountedPriceDecimal.ToString("C") End Sub Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click 'Clear previous amounts from the form. TitleTextBox.Clear() PriceTextBox.Clear() ExtendedPriceTextBox.Clear() DiscountTextBox.Clear() DiscountedPriceTextBox.Clear() With QuantityTextBox .Clear() .Focus() End With End Sub Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click 'Exit the program. Me.Close() End Sub Private Sub PriceTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PriceTextBox.TextChanged 'Display the price per book. PriceTextBox.Text = PriceDecimal.ToString("C") End Sub Private Sub BookSalesForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub QuantityTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuantityTextBox.TextChanged 'Display the number of books purchased numerically. QuantityInteger = Integer.Parse(QuantityTextBox.Text) End Sub Private Sub TitleTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TitleTextBox.TextChanged 'Display the title of the book. TitleTextBox.Text = TitleTextBox.Text End Sub Private Sub ExtendedPriceTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExtendedPriceTextBox.TextChanged 'Calculate the product. ExtendedPriceTextBox.Text = (QuantityInteger * PriceDecimal).ToString("C") End Sub Private Sub DiscountTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiscountTextBox.TextChanged 'Display the discount. DiscountTextBox.Text = Decimal.Parse(DISCOUNT_RATE_Decimal * ExtendedPriceDecimal).ToString("C") End Sub Private Sub DiscountedPriceTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DiscountedPriceTextBox.TextChanged 'Display the discounted price of the purchase) DiscountedPriceDecimal = (ExtendedPriceDecimal - DiscountDecimal).ToString("C") End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click 'Displays title Book Sales. End Sub End Class PROJECT: A company currently is having a sale with 15% discount . Need to be able to put the # of books, title of the book, price of the book. In another group calculate the extended price, calculate the 15% and have it display and then display the total cost of the book after the discount. Also to use try and catch blocks.
    40 pointsBadges:
    report
  • SRond
    Check out this book except, Murach’s VB 2008. It has some good tips on Visual Basic 2008 and coding
    95 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following