Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Textbox number format

Posted on 2004-10-21
6
Medium Priority
?
226 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:teamdad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 15

Accepted Solution

by:
Timbo87 earned 2000 total points
ID: 12375314
Change

intValue.ToString

to

intValue.ToString("00")
0
 
LVL 10

Expert Comment

by:james-ct16
ID: 12375374
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
 
LVL 10

Expert Comment

by:james-ct16
ID: 12375395
hi
looks like timbo jumped in with a neater anser as i was writing mine

james
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:teamdad
ID: 12375498
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
 
LVL 15

Expert Comment

by:Timbo87
ID: 12375595
Did you replace all occurences? It should change all of them since you're using a for each loop.
0
 

Author Comment

by:teamdad
ID: 12375819
Apparently I need my glasses changed..... I left off one of the ) on one of them.  Works great now.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question