Rounding numbers in VB6

Sharky Forums


Results 1 to 7 of 7

Thread: Rounding numbers in VB6

  1. #1
    Goldfish daftness101's Avatar
    Join Date
    Jun 2002
    Location
    Fresno, CA, US, NW Hemisphere, Earth, Milky Way
    Posts
    52

    Question Rounding numbers in VB6

    Hello. I'm having trouble with a program that I have to write for my computer concepts class that's due next month, when we actually cover VB. I'm not asking anyone to do my homework for me, since I've got everything I need done. The program does what it's supposed to do, but I can't figure out how to make the currency display in the textbox with only 2 numbers after the decimal instead of 4. Anyone have a good idea on how to do this?

    Here's what I have which is working fine:
    Code:
    Private Sub cmdCalculate_Click()
        Dim cBillAmt@, cTipAmt@
        Dim sPercent!
        
        cBillAmt@ = CCur(txtAmount.Text)
        sPercent! = CSng(txtPercentage.Text)
        cTipAmt@ = cBillAmt@ * sPercent!
        txtTipAmt.Text = "$" & CStr(cTipAmt@)
    End Sub
    Thanks in advance.

    -Daft
    Last edited by daftness101; 07-04-2002 at 03:24 PM.

  2. #2
    Tiger Shark
    Join Date
    Jun 2001
    Posts
    860
    FormatCurrency()

  3. #3
    Catfish df's Avatar
    Join Date
    Sep 2000
    Location
    Lexington VA(USA) + Melbourne(Aus)
    Posts
    146
    help->index search for "format" ??

  4. #4
    Goldfish daftness101's Avatar
    Join Date
    Jun 2002
    Location
    Fresno, CA, US, NW Hemisphere, Earth, Milky Way
    Posts
    52

    Thanks for the help

    Thanks guys. I'll look that up. I wish the book I'm reading would've covered that when it covered the different data types. Oh well, nothing's perfect. Thanks again.

    -Daft

  5. #5
    Goldfish daftness101's Avatar
    Join Date
    Jun 2002
    Location
    Fresno, CA, US, NW Hemisphere, Earth, Milky Way
    Posts
    52

    Can't search the index...no help in WM edition

    Well, I guess it would help if I had something other than the Working Model Edition. I just tried checking it out and it's telling me there's no help in the Working Model Edition. Well, no one ever said Microsoft was a user-friendly company. Oh well, I'll just wait until Monday when I have class to look it up. Thanks.

    -Daft

  6. #6
    Catfish df's Avatar
    Join Date
    Sep 2000
    Location
    Lexington VA(USA) + Melbourne(Aus)
    Posts
    146
    everyone has access to msdn.microsoft.com

    search for the format command, its very flexible.

    vb6 online documentation
    http://msdn.microsoft.com/library/de...bstartpage.htm

    vb6 format command
    http://msdn.microsoft.com/library/en...afctFormat.asp

  7. #7
    Goldfish daftness101's Avatar
    Join Date
    Jun 2002
    Location
    Fresno, CA, US, NW Hemisphere, Earth, Milky Way
    Posts
    52
    Thanks for the links df, I'm checking them out right now. I need to remember that there's MSDN...I just don't like searching MSDN, but that's just me.

    -Daft

Posting Permissions

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