Textbox number format

How can I get the textbox to show double digit numbers for the numbers 0 thru 9 instead of single digit numbers?


' Build lists of values matching min and max occurrence
        leastOccurring = New SortedList()
        mostOccurring = New SortedList()
        For Each de In frequencies
            intValue = CType(de.Key, Integer)
            valueFrequency = CType(de.Value, Integer)
            If valueFrequency = minOccurrence Then
                leastOccurring.Add(intValue, intValue)
            End If
            If valueFrequency = maxOccurrence Then
                mostOccurring.Add(intValue, intValue)
            End If
        Next

        ' Display the results in textbox
        Dim OccurringValues As String
        For Each intValue In leastOccurring.Values
            If OccurringValues = "" Then
                OccurringValues = intValue.ToString
            Else
                OccurringValues = OccurringValues & " - " & intValue.ToString
            End If
        Next
        TextBox1.Text = (OccurringValues)

        OccurringValues = ""
        For Each intValue In mostOccurring.Values
            If OccurringValues = "" Then
                OccurringValues = intValue.ToString
            Else
                OccurringValues = OccurringValues & " - " & intValue.ToString
            End If
        Next
        TextBox2.Text = (OccurringValues)
    End Sub
teamdadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Timbo87Commented:
Change

intValue.ToString

to

intValue.ToString("00")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
james-ct16Commented:
hi

there is a string format in the form of {**} that will do it but i end up spending ages looking it up everytime so i usually write meself a quick function to do it. find i can write it quicker than i cna look it up.

regards

james


code example follows
-------------------------

private function doubleDigit( byval val as interger) as string

if val <10 then
   return "0" & cstr(val)
else
   return cstr(val)
end if

end function

private function doubleDigit( byval val as string) as string

if val.length<2 then
  if va.length=0 then
     return "00"
  else
    return "0" & val
  end if
else
  return val
end if
end function
0
james-ct16Commented:
hi
looks like timbo jumped in with a neater anser as i was writing mine

james
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

teamdadAuthor Commented:
Using intValue.ToString("00") only changes the first number in my list of numbers.  It looks something like this: 01 - 2 - 3 - 4 but I need any numbers that are single digits to show as double digits.
0
Timbo87Commented:
Did you replace all occurences? It should change all of them since you're using a for each loop.
0
teamdadAuthor Commented:
Apparently I need my glasses changed..... I left off one of the ) on one of them.  Works great now.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.