0

Is it possible to Format the Text of a TextBox to display 3 digits even if the user has entered only a single digit?

e.g. the user entered "5", but I want to display it as "005".

I don't want to use MaskedTextBox.

In VB 6, it was as simple as
TextBox1.Text = Format(Val(TextBox1.Text),"000")

How can I get the same result in C# 2005??

Lalit Kumar Barik
India

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Eager_Beever
0

I don't have VS to verify this, but i believe string.Format() does the trick:

textBox1.Text = string.Format("{0:00000}", someNumber);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.