vbnet Generate UrlKey

Private Function GenerateUrlKey() As String
	Dim x As Int32 = 0
	Dim y As Int32 = 0
	Dim UrlKey As String = ""

	For x = 1 To My.Settings.KeyLength
		'Randomize the type of this character
		y = Int((3 * Rnd()) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase

		Select Case y
			Case 1
				'Numeric character
				Randomize()
				UrlKey = UrlKey & Chr(Int((9 * Rnd()) + 48))
			Case 2
				'Uppercase character
				Randomize()
				UrlKey = UrlKey & Chr(Int((25 * Rnd()) + 65))
			Case 3
				'Lowercase character
				Randomize()
				UrlKey = UrlKey & Chr(Int((25 * Rnd()) + 97))
		End Select
	Next

	'force lowercase from 2010-09-19 onwards
	Return UrlKey.ToLower()
End Function
Generates a UrlKey - as used on slck.it

Updated: Saturday 9th October 2010, 22:42pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.