Solved

Password generator in VB6

Posted on 2000-05-05
3
330 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 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