Results 1 to 20 of 20

Thread: Decimal Formatting Help

Hybrid View

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

    Re: Decimal Formatting Help

    E.g.
    vbn.et Code:
    1. Private Function GetFormatSpecifier(increment As Double) As String
    2.     Dim formatSpecifier As String
    3.     Dim text = increment.ToString()
    4.  
    5.     If text.Contains(".") Then
    6.         Dim fraction = text.Substring(text.IndexOf(".") + 1)
    7.  
    8.         formatSpecifier = "n" & fraction.Length
    9.     Else
    10.         formatSpecifier = "n0"
    11.     End If
    12.  
    13.     Return formatSpecifier
    14. End Function
    That's untested but I believe it should do the job. You can test and adjust if required.
    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

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Decimal Formatting Help

    Okay, I will test it

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2016
    Posts
    95

    Re: Decimal Formatting Help

    I've never worked with functions before, so where would I put it? Inside the button?

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