Hello All,
I have a quick question for everyone here. I have written a small program here using input boxes and a loop. The program goes off without a hitch but I can't seem to get the correct total to come up when working with cents. If I use whole dollar values then all is well but if a cent value is added to the program then the math isn't done correctly. Can any one of you fine gents give me a hand by skimming over the code I have so far?
VB Code:
'Variables are defined Dim intNumberItems As Integer = 0 'Var from inputbox CInt Dim intCount As Integer 'The loop counter Dim intTotal As Integer 'The accumulator intCount = 1 'Counter set to value intTotal = 0 'The accumulator set to value Dim strNumberItems As String 'Variable used for InputBox(Items) Dim strPrice As String 'Variable used for InputBox (Total) 'Open initial input box to inquire how many items need to be input strNumberItems = InputBox("How many items do you wish to input? ", _ "Enter Items") intNumberItems = CInt(strNumberItems) 'Set up loop to continue to show strPrice input box until 'intCount is equal to intNumberItems Do Until intCount > intNumberItems strPrice = InputBox("Enter the value of item # " & intCount.ToString _ & " into the box", "Enter item Value") 'Set intCount to count intCount += 1 intTotal += CInt(strPrice) Loop lblTotalAmount.Text = FormatCurrency(intTotal)
Thank you so much, you have no idea how much I value this site,
Abe
VB 2005 Express Edition




Reply With Quote