Can anyone help me to solve this problem? How to validate ?Thank you

Home identification code (4 alphanumeric characters) – required
Program should generate it using a random number generator


Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Me.Text = GenerateKey(4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    End Sub

    Private Function GenerateKey(nchars As Integer, fromStr As String) As String

        Dim rnd As New Random()
        Dim key As String = ""

        Do While key.Length < nchars
            key &= fromStr.Substring(rnd.Next(0, fromStr.Length), 1)

        Return key

    End Function

End Class

The Function, GenerateKey will generate a random string of the requested length from the given string. The segment

rnd.Next(0, fromStr.Length)

generates an index for selecting a random character from the string. If you want a different source string you can use

                "abcdefghijklmnopqrstuvwxyz" &

Dim key As String = GenerateKey(4, FROMSTR)