hello all,

been working on this assignment with the VB 2005 book for about a week now and i don't really understand where to go next. it's under lesson C exercise 3 where i have to calculate the amount of change and how many dollars, then quarters (dimes, nicks, pennies) that i have to give the customer.

i know that i need some type of if then statement but i'm not sure where to go with it and my program now is just locking up my PC. Help please.

oh and when you show me. tell me why i do it this way because it will really help me understand more.

thanx guys/gals

Public Class MainForm

    Dim TotalChange As Double


    Private Sub xButtonExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xButtonExit.Click
        Me.Close()

    End Sub

    Private Sub xButtonClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xButtonClear.Click
        'clear all fields and focus back to amount owed
        Me.xAmountOwedText.Text = String.Empty
        Me.xAmountPaidText.Text = String.Empty
        Me.xDollarsCalc.Text = String.Empty
        Me.xQuartCalc.Text = String.Empty
        Me.xDimeCalc.Text = String.Empty
        Me.xNickCalc.Text = String.Empty
        Me.xPennyCalc.Text = String.Empty

        Me.xAmountOwedText.Focus()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xCalculateButton.Click
        Dim Dolla As Integer
        Dim Quart As Integer

        'calculate the total change and assign to the correct text boxes
        TotalChange = Val(Me.xAmountPaidText.Text) - Val(Me.xAmountOwedText.Text)

        Integer.TryParse(Me.xDollarsCalc.Text, Dolla)
        If Dolla >= 1 Then
            Dolla = Dolla / 1
        End If

        Integer.TryParse(Me.xQuartCalc.Text, Quart)
        If TotalChange > 0.25 Then
            Quart = Me.xDollarsCalc.Text / 0.25
        End If

        'display message, tax and name
        Me.xMessageLabel.Text = "The change owed to the customer is " & Format(TotalChange, "currency")

    End Sub
End Class

so in the end it if i owe $23.76, it should look like:

Dollars Quarters Dimes Nickels Pennies
23 3 0 0 1

Any ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.