Formating and type Conversion

silent2k

New member
Joined
Jun 26, 2007
Messages
2
Programming Experience
Beginner
I have a Field: example R0123658-1
I am pulling that field and Removing the starting and ending characters to get
0123658
I am then converting it to an integer to get 123658 and adding 1 so I now have 123659 Then I format with "0000000" and convert back to string
and re add start and end characters. I am getting
R123659-1 instead of R0123659-1. Should I be doing something extra to keep leading zeros in an integer?
 
Try the padleft function rather than format.

Dim str as string = "123456"
str = str.padleft(7, "0"c)
Console.writeline(str)



output: 0123456

The format function is obsolete
 
seems to work. I am new to programming all together . Everywhere I searched referenced format. Thanks for the info.
 
The format function is obsolete

In the Microsoft.VisualBasic.Format sense of the word, I agree.. But String.Format() is very much alive, wonderful and essential tool for good programmers.. Be careful to ensure people know which you are referring to!
 
Back
Top