I am currently trying to learn how to program in VB and I'm stuck. Here is the code I am trying to work with, but my calculation doesn't work, when I click Calculate, I just get $0.00.
Any help would be great!!! Thanks!
Any help would be great!!! Thanks!
Code:
Option Explicit
Const mcurRate As Currency = 12.25
Dim mcurTotalAmount As Currency
Dim mintCount As Integer
Dim msngAverage As Single
Private Sub cmdCalculate_Click()
Dim curAmount As Currency
Dim intHours As Integer
'Convert Text to Value
curAmount = Val(txtAmount.Text)
'Calculate Amount
curAmount = intHours * mcurRate
'Format calculation values
txtAmount.Text = FormatCurrency(curAmount)
txtRate.Text = FormatCurrency(mcurRate)
End Sub
Private Sub cmdClear_Click()
txtHours = ""
txtRate = ""
txtAmount = ""
txtTotalAmount = ""
txtCount = ""
txtAverage = ""
txtHours.SetFocus
End Sub
Private Sub cmdEnd_Click()
End
End Sub
Private Sub cmdTotals_Click()
'Calculate summary values
mcurTotalAmount = mcurTotalAmount + mcurAmount
mintCount = mintCount + 1
msngAverage = mcurTotalAmount / mintCount
'Format summary values
mcurTotalAmount = Val(txtTotalAmount.Text)
txtTotalAmount.Text = FormatCurrency(mcurTotalAmount)
msngAverage = Val(txtAverage.Text)
txtAverage.Text = FormatCurrency(msngAverage, 2)
End Sub
Last edited by a moderator: