why I set the format to 0000, but it doesn't work?
here is my code
if my textbox1 is 0123, it just show me 123...Code:Dim loud As Integer
loud = TextBox1.Text
loud = Format(loud, "0000")
console.writeln(loud)
Printable View
why I set the format to 0000, but it doesn't work?
here is my code
if my textbox1 is 0123, it just show me 123...Code:Dim loud As Integer
loud = TextBox1.Text
loud = Format(loud, "0000")
console.writeln(loud)
Code:Dim loud As Integer
If Integer.TryParse(TextBox1.Text, loud) Then
Debug.WriteLine(loud.ToString("0000"))
Else
Debug.WriteLine("Invalid number")
End If
so, is that right?
loud = loud.tostring("0000")
Nevermind, stanav beat me to the punch. :wave:
D
stanav gave you the solution you were asking for. Did you give it a shot?Quote:
Originally Posted by newpat
In addition, here is some more on formatting:
http://msdn2.microsoft.com/en-us/lib...sy(VS.80).aspx
but how can I save the 0123 to loud?Quote:
Originally Posted by stanav
I tried, although it come out with "0123", I dun know how can I save it to loud.:(
Integers do not have leading zeros. Save it to a string variable if you must have the leading zero.
vb.net Code:
' loud Dim loud As Integer = 123 Dim str As String = loud.ToString("0000") MessageBox.Show(str)
No, that's not what I meant....Quote:
Originally Posted by newpat
What you have displayed on screen is just a string representation of the integer value. And you can not format an integer itself but rather its string representation. That's why you have to to convert the integer to string and then format that string.
ok then...My integer is to compare with another integer...
However, I have found out another way to do my expection.
Thx for all!