CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2001
    Posts
    37

    random string VBScript

    hello,

    I want to generate random password for first time use when registration is completed. How to genereate random string/integeer or combination of both in VBScript>?

    thanks

    chris


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: random string VBScript

    The following code will produce a strpassword containing 10 alphanumeric characters.


    dim rndnum as integer, rndsel as integer, rndchr as integer
    dim strpassword as string
    strpassword = ""
    for i = 1 to 10
    rndnum = int(rnd * 10) + 48
    rndchr = int(rnd * 26) + 65
    rndsel = int(rnd * 2)
    strPassword = strpassword & chr$(iif(rndsel = 0, rndnum, rndchr))
    next





  3. #3
    Join Date
    Feb 2001
    Posts
    37

    Re: random string VBScript

    this is for VB, i need it inside my ASP page...i cannot use the iif function in VBScript...

    thanks anyway =)
    anymore help plz!!

    chris



  4. #4
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: random string VBScript

    then declare a variable chrtouse


    if rndsel = 0 then
    chrtouse = chr$(rndnum)
    else
    chrtouse = chr$(rndchr)
    endif

    strpassword = strpassword & chrtouse





    instead of

    strpassword = strpassword & chr$(iif(...))



  5. #5
    Join Date
    Feb 2001
    Posts
    37

    Re: random string VBScript

    well..it does generate random number...but when another user register, it'll generate exactly the same password....and we dun want that to happen...


    chris


  6. #6
    Join Date
    Feb 2001
    Posts
    37

    Fix: random string VBScript

    hi, thanks a lot man for your help! =)
    i've solved the problem...i just put "Randomize" at the beginning of each loop...that would do...

    thanks!!


    chris


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured