Results 1 to 4 of 4

Thread: [RESOLVED] 2 Questions about Decimals

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Resolved [RESOLVED] 2 Questions about Decimals

    Hey guys. I got two problems. Firstly, instead of the program saying 0.5 or 0.6 or 0.42703000 all the time I want it to say:

    .5
    .6
    .42703000


    Is there a global option for this or atleast a code for me to put into each one?


    Second:


    I have two arrays. One has about 100 different numbers. When I view the array I want it to have 4 numbers after the decimal at ALL times. For example...

    1.4000
    2.3500
    1.4555
    7456.4000


    etc... Thanks for any help!

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2006
    Location
    Pennsylvania
    Posts
    1,069

    Re: 2 Questions about Decimals

    ehh.. I got it. I used this:

    ToString(#.0000);

  3. #3
    Frenzied Member conipto's Avatar
    Join Date
    Jun 2005
    Location
    Chicago
    Posts
    1,175

    Re: 2 Questions about Decimals

    Quote Originally Posted by Fromethius
    ehh.. I got it. I used this:

    ToString(#.0000);
    No you didn't.

    You used

    ToString("#.0000");



    Bill
    Hate Adobe Acrobat? My Codebank Sumbissions - Easy CodeDom Expression evaluator: (VB / C# ) -- C# Scrolling Text Display

    I Like to code when drunk. Don't say you weren't warned.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] 2 Questions about Decimals

    That's not going to work if you have more than four decimal places. This will work in all cases:
    VB Code:
    1. nyNumber.ToString().TrimStart("0"c)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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