Hi all , I am trying to get input from user then convert it into specific format and hold it in new variable.
here is my code

Dim dtmInputBox As String = ""
            'Dim strDTM As String '= ""
            Do Until Not dtmInputBox = Nothing
                dtmInputBox = InputBox("Enetr DTM Value", "DTM Value Form", "0")
                Dim strDTM As String = String.Format("000000", dtmInputBox)

            Loop

i type 15 then it should be like 000015
any body can sole it , plz urgent

Dim strDTM As String = dtmInputBox.PadLeft(6, "0")
will fill your string with leading 0 on a total length of 6

Thanks GeekByChoice, its great working
Can u plz explain what is wrong with
Dim strDTM As String = String.Format("000000", dtmInputBox)
or
Dim strDTM As String = String.Format("{0:000000}", dtmInputBox) -->this produce what i type like i keyin 15 its result is 15

Please read the String.Format MSDN article.

syntax:

{index[,length][:formatString]}

Thanks alot

its working now

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.