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 7939189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:01:43+00:00 2026-06-03T23:01:43+00:00

My form contains several NumericUpDown controls. These controls show different amount of decimal places.

  • 0

My form contains several NumericUpDown controls. These controls show different amount of decimal places.
Later in my code I put the different NumericUpDown.Value‘s in a string array arrStr() like so:

arrStr(1) = NumericUpDown1.Value
arrStr(2) = NumericUpDown2.Value
arrStr(3) = NumericUpDown3.Value

Then I print the array with the File.WriteAllLines function to a text file.
If for example NumericUpDown1.Value = 1.00, NumericUpDown2.Value = 2.30 and NumericUpDown3.Value = 2.124 the file has the following values in it:

1
2.3
2.124

I would like to see:

1.00
2.30
2.124

I have tried Format which works, but that formatting method is not convenient as the amount of decimal places is already set for each NumericUpDown. It would be annoying to do the work again, but now with Format.

  • 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-06-03T23:01:45+00:00Added an answer on June 3, 2026 at 11:01 pm

    You could use String.Format to force two decimal places:

    Dim value As Double = 2.3
    Dim formatted = String.Format("{0:f2}", value) ' 2.30 '
    

    Standard Numeric Format Strings

    Edit: If you’re array is large and you want to avoid:

    arrStr(1) = String.Format("{0:f2}", NumericUpDown1.Value) up to arrStr(86) = String.Format("{0:f2}", NumericUpDown86.Value)

    You can use LINQ to create the array. Assuming that your NumericUpDown controls are all in a GroupBox called NumericGroupBox. You can “inject” the correct number of decimal places:

    Dim arrStr() As String =
            (From n In NumericGroupBox.Controls.OfType(Of NumericUpDown)()
            Select String.Format("{0:f" & n.DecimalPlaces & "}", n.Value)).ToArray()
    

    and here’s a version that searches all TabPages of your TabControl(as commented):

    Dim allNumerics = From tp In Me.TabControl1.TabPages.Cast(Of TabPage)()
                      From n In tp.Controls.OfType(Of NumericUpDown)()
                      Select String.Format("{0:f" & n.DecimalPlaces & "}", n.Value)
    Dim arrStr As String() = allNumerics.ToArray()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which contains several standard controls (textbox's, buttons, etc). I want
I have a form that contains several buttons. I want to have the form
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I made a form to create an account which contains several fields. Those are:
I have a one form tag inside my Index.aspx view. Index.aspx contains several partial
For my C# Windows Form Application, I have created a flowlayoutpanel that contains several
I have a JSF page that contains a form with several elements, that correspond
I have a windows form. It contains several datagridviews on it. At some point,
I have a .NET UserControl (FFX 3.5). This control contains several child Controls -
I have a search form that allows users to search on several different fields

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.