Results 1 to 5 of 5

Thread: FormatCurrency not coming out correctly.

Threaded View

  1. #1

    Thread Starter
    Addicted Member Abrium's Avatar
    Join Date
    Feb 2007
    Location
    The Great State of Texas
    Posts
    205

    Resolved FormatCurrency not coming out correctly.

    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:
    1. 'Variables are defined  
    2.         Dim intNumberItems As Integer = 0 'Var from inputbox CInt
    3.         Dim intCount As Integer           'The loop counter
    4.         Dim intTotal As Integer           'The accumulator
    5.         intCount = 1                      'Counter set to value
    6.         intTotal = 0                      'The accumulator set to value
    7.         Dim strNumberItems As String      'Variable used for InputBox(Items)
    8.         Dim strPrice As String            'Variable used for InputBox (Total)
    9.  
    10.         'Open initial input box to inquire how many items need to be input
    11.         strNumberItems = InputBox("How many items do you wish to input? ", _
    12.         "Enter Items")
    13.         intNumberItems = CInt(strNumberItems)
    14.  
    15.  
    16.         'Set up loop to continue to show strPrice input box until
    17.         'intCount is equal to intNumberItems
    18.         Do Until intCount > intNumberItems
    19.  
    20.             strPrice = InputBox("Enter the value of item # " & intCount.ToString _
    21.             & " into the box", "Enter item Value")
    22.  
    23.  
    24.             'Set intCount to count
    25.             intCount += 1
    26.             intTotal += CInt(strPrice)
    27.  
    28.         Loop
    29.  
    30.  
    31.         lblTotalAmount.Text = FormatCurrency(intTotal)

    Thank you so much, you have no idea how much I value this site,
    Abe
    VB 2005 Express Edition
    Last edited by Abrium; Feb 20th, 2007 at 04:04 AM. Reason: Forgot to add version being used

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