كود :
Public Class Form1
Dim lst As New List(Of String)
Dim a, s, d, f As Integer
Dim b, b2 As Long
Public Function GeneratePassword(ByVal Length As Integer) As String
' Creates a memorable password of the specified Length
Dim blnOnVowel As Boolean
Dim strTempLetter As String
Dim strPassword As String
Dim intCount As Integer
For intCount = 1 To Length
If blnOnVowel = False Then
' Choose a nice consonant - no C, X, Z, or Q
strTempLetter = CType(Choose(CType(GetRandomNumber(1, 17), Double),
"B", "D", "F", "G", "H", "J", "K", "L", "M",
"N", "P", "R", "S", "T", "V", "W", "Y"), String)
' Append it to the password string
strPassword += strTempLetter
' Swich to vowel mode
blnOnVowel = True
Else
' Choose a vowel
strTempLetter = CType(Choose(CType(GetRandomNumber(1, 5), Double),
"A", "E", "I", "O", "U"), String)
' Append it to the password string
strPassword += strTempLetter
' Switch back again, ready for next loop round
blnOnVowel = False
End If
Next
Return strPassword
End Function
Dim objRandom As New System.Random(CType((System.DateTime.Now.Ticks _
Mod System.Int32.MaxValue), Integer))
Public Function GetRandomNumber(Optional ByVal Low As Integer = 1,
Optional ByVal High As Integer = 100) As Integer
' Returns a random number,
' between the optional Low and High parameters
Return objRandom.Next(Low, High + 1)
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Randomize()
gn:
a = Rnd() * 999999
f = Rnd() * 999999
If lst.Contains(a) Then
GoTo gn
End If
lst.Add(a)
Dim M As System.Text.RegularExpressions.Match
M = System.Text.RegularExpressions.Regex.Match(a & GeneratePassword(8) & f & GeneratePassword(4), "(\d+)([^0-9]+)(\d+)([^0-9]+)")
b = M.Groups(1).Value
b2 = M.Groups(3).Value
b *= 100
b += 1000
b -= 2
b2 *= 100
b2 += 1000
b2 -= 2
TextBox1.Text = b & M.Groups(2).Value & b2 & M.Groups(4).Value
Form2.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox2.Text = b Then
MsgBox("Yes")
Else
MsgBox("No")
End If
End Sub
End Class