Results 1 to 9 of 9

Thread: Decimal placement more than 3 digits?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Decimal placement more than 3 digits?

    Hello, I am making this application and I need the decimal placement to go past 3 digits after the decimal is placed. I would do double but that seems to mess the program up with unwanted digits. I am different radio button options like tenths place, hundreths place, etc... all the way to millionths. It will go to thousandths and that is where it is lastly effective before it can not go up anymore numbers anymore. Replies are appreciated, thanks!

  2. #2
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    279

    Re: Decimal placement more than 3 digits?

    try

    format(txtdata.text,"0##.00")


    for reference if it is useful

  3. #3
    Fanatic Member
    Join Date
    Nov 2016
    Location
    Slovenia
    Posts
    575

    Re: Decimal placement more than 3 digits?

    Hello, I am making this application and I need the decimal placement to go past 3 digits after the decimal is placed.
    You question is pretty unclear, so I reckon that you just need proper format for your numbers:

    Code:
     Dim value As Integer = 1234567891
       MsgBox(value.ToString("N0") 'zero and not "O" character
       'Result is 1.234.567.891
       'Or Msgbox(value.ToString("N3")) - result is 1.234.567.891,000
    You can use Double too. And you might a look at this for future formats:
    https://msdn.microsoft.com/en-us/lib...code-snippet-1

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Decimal placement more than 3 digits?

    1) yes, don't use the double... use the Decimal type...
    2) Don't confuse the value with the display...
    3) since you haven't shown any code, I'm not sure what the issue is... so, refer back to item 1 in this list.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Decimal placement more than 3 digits?

    Alright, somewhat what I want. It stops at 0.001 but I need it to go as far as 0.00001

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Decimal placement more than 3 digits?

    What do you meant "Stops"? Keep in mind, we haven't the foggiest idea what you're doing since you haven't shown what code you're using.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Decimal placement more than 3 digits?

    What I mean is this: I have 6 Options. Tenths, Hundredths, Thousandths, Ten-Hundredths, Ten-Thousandths, and Millionths. The format for Thousandths is 0.001 and when I try millionths it should be 0.000001 but the displayed format is 0.001
    Here is some code:
    Code:
        Sub Millionths()
            startNum = txtStart.Text
            EndNum = txtEnd.Text
            While (startNum >= EndNum + 0.000001)
                counter += 1
                startNum -= 0.001
                Data += startNum & vbNewLine
            End While
            starting = txtStart.Text
            rtbDisplay.Text = starting & vbNewLine & Data & vbNewLine
            lblCount.Text = counter
        End Sub
    Declares(At start of program):
    Code:
        Dim startNum, starting As Decimal
        Dim EndNum As Decimal
        Dim Data As String
        Dim counter As Integer = 0
    Last edited by Dragnorian; Jan 19th, 2017 at 11:22 PM. Reason: Added Code

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

    Re: Decimal placement more than 3 digits?

    You already have all the information you need from post #3. Did you follow the link provided there?
    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

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Decimal placement more than 3 digits?

    Oh I didn't even notice that link lol, I will look at in a bit. Thanks for pointing that out!

Tags for this Thread

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