User:Cakemix/Snippets/VB/Generate Serial

Digit input:

Imports System.Text

Public Class Form1

Private Function Cakemix(ByVal size As Integer) As String Dim builder As New StringBuilder Dim random As New Random Dim i, u As Integer builder.Append("XXXXX") For i = 0 To size builder.Append("-") For u = 0 To size builder.Append(random.Next(1, 9)) Next Next Return builder.ToString End Function Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MsgBox(Cakemix(3)) End Sub End Class

Output:

XXXXX-5718-7783-3127-1421