[RESOLVED] [2005] What happened to string() in vb.net?
Here I am trying to take an input number value by a user and add X number of preceeding 0's to it to make it have a total of 9 digits.
They input "37" then I want: 000000037
They input "4050" then I want: 000004050
(They will never enter more than 4 digits, sort of besides the point)
I recall using the old string() function in vb6 where I would whip up something like:
new_string$ = string(9 - len(uservalue), "0") & uservalue
(man, those were the days!)
How can I do the equivalent in vb.net without ugly if statements or recursive code? It seems the string() function is gone, right?
Thank you guys as always!
-Josh
Re: [2005] What happened to string() in vb.net?
Try this
VB Code:
Dim ss As String
ss = Format(4512, "000000000")
Re: [2005] What happened to string() in vb.net?
Great!
I use the format function all the time and dummy me never even thought of or realized that! Kudos to you and thank you for your time!
Re: [RESOLVED] [2005] What happened to string() in vb.net?
VB Code:
Dim MyNumber As Integer = 4050
MessageBox.Show(MyNumber.ToString.PadLeft(9, "0"))