to create unique reference i had below code in vb6

Dim UNKREFBATCH As String
UNKREFBATCH = "B" & Format(Date, "MMDD") & Format(Time, "HHMMSS")

but the same is not giving correct result in vb.net

 Dim UNKREFBATCH As String

 UNKREFBATCH = "B" & Format(Date.Now, "MMDD") & Format(DateTime.Now, "HHMMSS")

 MsgBox(UNKREFBATCH)

instead of minutes its showing month and showing DD or SS for "DD" or "SS"

How can i get same result as in vb6

Minutes is mm instead of MM

 UNKREFBATCH = "B" & Format(Date.Now, "MMdd") & Format(DateTime.Now, "HHmmss")

this gives result as required

thanks

There is already a builtin way to generate a unique reference. It's called a GUID and you can use it as follows:

Dim g As System.Guid = System.Guid.NewGuid

It will generate a result of the form

e57bf525-4b8e-4d09-98aa-53fe997acfb8