Results 1 to 8 of 8

Thread: Function help

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2007
    Posts
    6

    Function help

    Hello i recently started to use functions but do not understand the concept. I have worked on a project out of a book that adds coins(quarters, dimes, nickels, pennies) and adds them all up using a function. This is what i have done:

    Dim sngCalculate As Single
    --------------------------------------------------------------------------
    Private Sub btnAddCoins_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddCoins.Click
    Dim sngQuarters As Single = Val(Me.txtValue1.Text)
    Dim sngDimes As Single = Val(Me.txtValue2.Text)
    Dim sngNickels As Single = Val(Me.txtValue3.Text)
    Dim sngPennies As Single = Val(Me.txtValue4.Text)

    sngQuarters = sngQuarters * 25
    sngDimes = sngDimes * 5
    sngNickels = sngNickels * 10
    sngPennies = sngPennies * 1

    Me.lblAnswer.Text = Calculate(sngCalculate)
    End Sub
    --------------------------------------------------------------------------
    Function Calculate(ByVal sngQuarters As Single, ByVal sngDimes _
    As Single, ByVal sngNickels As Single, ByVal sngPennies As Single) As Single

    sngCalculate = sngQuarters * sngDimes * sngNickels * sngPennies
    Return sngCalculate
    End Function

    End Class
    This does not work and i am uncertain of if i am doing the function correctly. Any help would be greatly appreciated. So far it adds everything to 0.
    Last edited by Inugami; Feb 6th, 2007 at 09:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width