Solved

Password generator in VB6

Posted on 2000-05-05
3
321 Views
Last Modified: 2008-02-01
I'm a newbie in VB6 and I need a program to generate multiple passwords with letters and numbers of different lenght. Help me please...
0
Comment
Question by:rogerleblond
  • 2
3 Comments
 
LVL 13

Expert Comment

by:crazyman
ID: 2780388
This would make a string of random characters and numbers and random length between the values passed.


Public Function MakePassWord(minLength As Integer, maxLength As Integer) As String
      Dim x As Integer
      Dim y As Integer
      Dim z As Integer
      Dim strout As String
      Randomize
      x = Int((maxLength * Rnd) + minLength)
      For y = 1 To x
            Randomize
            z = CInt((255 * Rnd) + 1)
            strout = strout & Chr(z)
      Next y
      MakePassWord = strout
End Function

Private Sub Command1_Click()
      MakePassWord 1, 22
End Sub



u could easy mod it just to create letters and numbers and not strange characters
0
 
LVL 13

Expert Comment

by:crazyman
ID: 2780436
Heres a better one.



Option Explicit

Public Function MakePassWord(minLength As Integer, maxLength As Integer) As String
      Dim x As Integer
      Dim y As Integer
      Dim z As Integer
      Dim strout As String
      Randomize
      x = Int((maxLength * Rnd) + minLength)
      For y = 1 To x
            Randomize
            z = CInt((255 * Rnd) + 1)
            Do While (z < 65 Or z > 90) And (z < 97 Or z > 122) And (z > 57 Or z < 48)
                  Randomize
                  z = CInt((255 * Rnd) + 1)
            Loop
            strout = strout & Chr(z)
      Next y
      MakePassWord = strout
End Function

Private Sub Command1_Click()
     MsgBox (MakePassWord(1, 22))
End Sub
0
 
LVL 1

Accepted Solution

by:
garrenb earned 100 total points
ID: 2780968
Hi,

Here is a version on a routine I wrote to generate a password based on the user's name. The important line is the 'CODEUP' bit. This generates the small alogrithm. Hope this helps ...

Dim TheDate As Date   ' Declare variables.
        primedate = "15/03/1968"
        TheDate = Date
        dayz = DateDiff("d", primedate, TheDate)
        Password = TxtPword.Text
        passlong = Len(Password)
       
        Dim word(250)
       
        For loopy = 1 To passlong
            word(loopy) = Mid$(Password, loopy, 1)
        Next
       
        codeup = dayz
       
        For loopy = 1 To passlong
            codeup = codeup & ((Asc(word(loopy)) * 2) + dayz + 633) 'Add 633 This Could be anything
        Next
       
        Text2.Text = codeup
        TxtPword.Text = ""
        TxtRetype.Text = ""

        Call CmdCommit_Click
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now