asp.net verification

Source: Internet
Author: User
Tags datetime integer mscorlib rand random seed return
asp.net

Before I found a C # verification test, but there is a sentence with vb.net can not find how to write, so that for a long time my verification is repeated, today in the small cobblestone network friend's patience Point, with Dim aa as Integer = CType (DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer) is a random seed, but it is normal to perform in a disconnected situation, and if not, the unhandled exception of System.StackOverflowException ' will happen Mscorlib.dll's Mistakes

So the revised code is as follows, always running out of its own satisfying results

Dim Allchar as String = "A,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i, J,k,l,m,n,o,p,q,r,s,t,u,w,x,y,z "
Dim Allchararray () as String = Allchar.split (",")
Dim Randomcode as String = ""
Dim temp as Integer =-1
Dim Rand as Random = New Random
Dim i as Integer = 0
Do while (I < codecount)
If (temp <> 1) Then
' Rand = New Random (i * temp) if it's not there, it's always going to happen again.
Dim aa as Integer = CType (DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer) ' with vb.net notation, remove the multiplication of I and temp

                rand = New Random (aa )
            End If
             Dim T as Integer = rand. Next (61) + 1 ' +1 is a rewrite, 61 represents the total number of characters, the index value starts from 0
            If t > allchararray.length-1 Then t = allchararray.length-1 ' rewrite
        & nbsp;   If temp = t Then ' The continuous recovery of the authenticator
                 '     return Createrandomcode (Codecount) Mscorlib.dll's dead End
                 I-= 1 ' rewrite
                 Randomcode = Microsoft.VisualBasic.Left ( Randomcode, i) ' rewrite

End If
temp = t
Randomcode = Randomcode + allchararray (t)
i + 1
Loop

Return Randomcode

Not as much as books, this is the most I want to say a word, do not let the letter beam bondage their own thoughts oh ^__^



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.