0

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

Edited by PM312

3
Contributors
3
Replies
11
Views
3 Years
Discussion Span
Last Post by Reverend Jim
0
 UNKREFBATCH = "B" & Format(Date.Now, "MMdd") & Format(DateTime.Now, "HHmmss")

this gives result as required

thanks

0

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

Edited by Reverend Jim

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.