Formatting number with leading zeroes

dranko

Member
Joined
Apr 16, 2006
Messages
16
Programming Experience
Beginner
I have a textbox bound to datatable column(integer type). What user want is when number is for example 5, to show 0005, or 35 to show 0035 (4 places).
How to format textbox to get that.
I was trying this:

BrojOtprTextBox.Text.ToString("0000")

but it doesn't work.
 
Last edited:
Bob Langlade said:
You can try this :
VB.NET:
Dim Result As Integer
Dim IsInteger As Boolean
IsInteger = Integer.TryParse(BrojOtprTextBox.Text, Result)
If IsInteger Then
BrojOtprTextBox.Text = Result.ToString("0000")
        End If
Thanks Bob, that's what I needed.
 
Back
Top