I am trying to write a code which will combine these values and format it in the following format to be used as control/validation ID. I have written a line of code that will merge these values together into a long string but I can't get the zeros to fill in. For month, I get 4 instead of 04 and for numeric value I get 1 digit number instead of having numbers with 0 padding to the left.
Can anyone help me put these in order?

'IN' + Year(YYYY) + Month(MM) + Numeric(0000)
Example:
Control 1 for April 2011
IN2011040001
Control 2 for April 2011
IN2011040002
Control 1 for May 2011
IN2011050001

Dim TestMonth As String = Format(Month(Now), "MM")
        Dim TestYear As String = Format(Year(Now), "YYYY")
        Dim TestNum As Integer

txtTest1.Text = "IN" & TestYear & TestMonth & ToString(TestNum+1)

This will do the trick:

Dim TestNum As Integer 
txtTest1.Text = "IN" & Format(Now.Year,"0000") & Format(Now.Month,"00") & Format(TestNum+1,"0000")

hey it worked.
Thanks dxider

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.