Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Password generator in VB6

Posted on 2000-05-05
3
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

636 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