covert string to particular pattern
-
Hi All, For example im having a string like this "0:30:1A:1E:55:2" i want to convert this string to "00:30:1A:1E:55:02" how can i do this. right now im split the string using ':' and then find the length if its 1 then add 0 in front of it, it works fine for me.... but i think some simpler way must be there.... so plz guide me if am wrong With Regards Amjath
-
Hi All, For example im having a string like this "0:30:1A:1E:55:2" i want to convert this string to "00:30:1A:1E:55:02" how can i do this. right now im split the string using ':' and then find the length if its 1 then add 0 in front of it, it works fine for me.... but i think some simpler way must be there.... so plz guide me if am wrong With Regards Amjath
Amjath Rahman wrote:
add 0 in front of it
String.PadLeft Method[^]
Dim str As String Dim pad As Char str = "forty-two" pad = "."c Console.WriteLine(str.PadLeft(15, pad)) ' Displays "......forty-two". Console.WriteLine(str.PadLeft(2, pad)) ' Displays "forty-two".
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)