T
tshad
I have a page that I am getting a username and password as a random number
(2 letters, one number and 4 more letters)
I have 2 functions I call:
*************************************************
Function RandomString(size as integer, lowerCase as boolean) as string
Dim builder as StringBuilder = new StringBuilder()
Dim random as Random = new Random()
Dim i as integer
dim ch as char
for i = 0 to size -1
ch = Convert.ToChar(Convert.ToInt32(25 * random.NextDouble() + 65))
random.NextDouble()
builder.Append(ch)
next
if(lowerCase) then RandomString = builder.ToString().ToLower()
RandomString = builder.ToString()
end function
*********************************************************
Function GetRandom() As String
Dim builder as StringBuilder = new StringBuilder()
builder.Append(RandomString(6, false))
builder.insert(2,RandomNumber(0, 10))
GetRandom = builder.ToString()
End Function
***********************************************************
I call GetRandom to get the numbers in 2 places in my page:
Password.Text = GetRandom()
UserName.Text = GetRandom()
These give me the same number on the same page. Is there a way around this?
Thanks,
Tom
(2 letters, one number and 4 more letters)
I have 2 functions I call:
*************************************************
Function RandomString(size as integer, lowerCase as boolean) as string
Dim builder as StringBuilder = new StringBuilder()
Dim random as Random = new Random()
Dim i as integer
dim ch as char
for i = 0 to size -1
ch = Convert.ToChar(Convert.ToInt32(25 * random.NextDouble() + 65))
random.NextDouble()
builder.Append(ch)
next
if(lowerCase) then RandomString = builder.ToString().ToLower()
RandomString = builder.ToString()
end function
*********************************************************
Function GetRandom() As String
Dim builder as StringBuilder = new StringBuilder()
builder.Append(RandomString(6, false))
builder.insert(2,RandomNumber(0, 10))
GetRandom = builder.ToString()
End Function
***********************************************************
I call GetRandom to get the numbers in 2 places in my page:
Password.Text = GetRandom()
UserName.Text = GetRandom()
These give me the same number on the same page. Is there a way around this?
Thanks,
Tom