Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 759213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:34:09+00:00 2026-05-14T15:34:09+00:00

I am writing a custom totaling method for a grid view. I am totaling

  • 0

I am writing a custom totaling method for a grid view. I am totaling fairly large numbers so I’d like to use a decimal to get the total. The problem is I need to control the maximum length of the total number. To solve this problem I started using float but it doesn’t seem to support large enough numbers, I get this in the totals column(1.551538E+07). So is there some formating string I can use in .ToString() to guarentee that I never get more then X characters in the total field? Keep in mind I’m totaling integers and decimals.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:34:09+00:00Added an answer on May 14, 2026 at 3:34 pm

    If you’re fine with all numbers displaying in scientific notation, you could go with "E[numberOfDecimalPlaces]" as your format string.

    For example, if you want to cap your strings at, say, 12 characters, then, accounting for the one character for the decimal point and five characters needed to display the exponential part, you could do:

    Function FormatDecimal(ByVal value As Decimal) As String
        If value >= 0D Then
            Return value.ToString("E5")
        Else
            ' negative sign eats up another character '
            Return value.ToString("E4")
        End If
    End Function
    

    Here’s a simple demo of this function:

    Dim d(5) As Decimal
    
    d(0) = 1.203D
    d(1) = 0D
    d(2) = 1231234789.432412341239873D
    d(3) = 33.3218403820498320498320498234D
    d(4) = -0.314453908342094D
    d(5) = 000032131231285432940D
    
    For Each value As Decimal in d
        Console.WriteLine(FormatDecimal(value))
    Next
    

    Output:

    1.20300E+000
    0.00000E+000
    1.23123E+009
    3.33218E+001
    -3.1445E-001
    3.21312E+016
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm aware of writing custom attributes that decorate a method and get evaluated before
I am writing a custom .pac script for use with Firefox. Following numerous examples
I'm writing a custom flex file to generate a lexer for use with JSyntaxpane.
I am constantly writing custom WebParts but after I deploy them, they always get
I created custom django-admin command. I use this tutorial Writing custom django-admin commands For
Recently I've decided to get some knowledge about writing custom tags. And there is
Overview of the problem: I've been playing with writing custom http server apps for
I am writing a custom ConfigurationElementCollection for a custom ConfigurationHandler in C#.NET 3.5 and
I'm writing a custom deserializer that will deserialize a list by deserializing each of
I am writing a custom wrapper for open_flash_chart plugin. It's placed in /lib and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.