CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: String Format

  1. #1
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    String Format

    Looking for a better/simpler way to format a fixed length dollar and cents string. I want to format the string to 10 positions with the last 2 positions being the cents without the decimal point. For example 86.38 needs to be 0000008638. Here is what I currently have:


    Dim TPAmt as string 'TP dollar amount
    Dim TPCents as string 'TP cents amount


    TPCents = Right$(txtData(3), 2) 'TP Cents

    'set and format Amount variables
    TPAmt = Fix(txtData(3).Text)
    TPAmt = Format$(TPAmt, "00000000") & TPCents






  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: String Format

    Try:

    TPAmt = Format$((txtData(3).Text * 100), "0000000000")




    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: String Format

    Tx-Yours is the simpler solution I knew there had to be. I'm brain dead today. Staying up late and getting up at 5:00 AM doesn't make for clear thinking.


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

Featured