I am trying to run this code in a form when a user double clicks in a particular field. I am unsure how I should do it since it uses 2 text files, one to generate and the other to store to eleminate redundancy. If you can help this newbie, thanks. -
'==========================================================================
-
'
-
' NAME: RandomPasswordGenerator.vbs
-
'
-
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
-
' URL: http://www.thespidersparlor.com
-
' DATE : 7/29/2004
-
' Modified by Homer Simpson, 9/05/2007 for Wire Room Pin generation
-
'
-
' COMMENT: Generates Random Passwords meeting "Complex" Requirements
-
' By default will generate a 4 digit password.
-
' Edit line passLen = 4 to change length
-
'==========================================================================
-
Option Explicit
-
'On Error Resume Next
-
-
Dim BankCode, newpass, passList, inFlag, pgLength, x, fso, ts, passLen, WshShell, passin
-
Const ForWriting = 2, ForAppending = 8, ForReading = 1
-
passLen = 4
-
-
'Give inFlag (input Flag) an initial value to ensure we run once
-
inFlag = "invalid"
-
-
Do While inFlag = "invalid"
-
BankCode = InputBox("Enter a valid Bank Code")
-
-
'Quit if no entry
-
If BankCode = "" Then WScript.Quit
-
BankCode=UCase(BankCode)
-
'copy this line per bank. Put codes in upper case
-
If (BankCode = "BW") or (BankCode = "BWE") then inFlag = "valid"
-
If (BankCode = "CB") or (BankCode = "CBE") then inFlag = "valid"
-
If (BankCode = "FB") or (BankCode = "FBE") then inFlag = "valid"
-
If (BankCode = "MB") or (BankCode = "MBE") then inFlag = "valid"
-
If (BankCode = "MM") or (BankCode = "MME") then inFlag = "valid"
-
If (BankCode = "ON") or (BankCode = "ONE") then inFlag = "valid"
-
Loop
-
-
-
'Generate the PIN
-
inFlag= "invalid"
-
Do While inFlag = "invalid"
-
set ts = nothing
-
set fso = nothing
-
Set fso = CreateObject("Scripting.FileSystemObject")
-
Set ts = fso.OpenTextFile ("PasswordList.txt", ForReading)
-
newpass = generatePassword(passLen)
-
newpass = BankCode + newpass
-
-
' validate password uniqueness
-
-
inflag="valid"
-
Do While ts.AtEndOfStream <> true
-
passin=ts.ReadLine
-
if passin = newpass then inFlag="invalid"
-
Loop
-
Loop
-
set ts = nothing
-
set fso = nothing
-
-
'Now save it all to a text file.
-
passList = newpass & vbCrLf
-
Set fso = CreateObject("Scripting.FileSystemObject")
-
Set ts = fso.CreateTextFile ("NewPin.txt", ForWriting)
-
ts.write passList
-
-
set ts = nothing
-
set fso = nothing
-
-
'Open PIN in notepad
-
set WshShell = WScript.CreateObject("WScript.Shell")
-
-
'Launch Notepad from the command line
-
WshShell.Run "Notepad.exe NewPin.txt"
-
-
'Write Password to permanent list
-
Set fso = CreateObject("Scripting.FileSystemObject")
-
Set ts = fso.OpenTextFile ("PasswordList.txt", ForAppending)
-
ts.write passList
-
-
set ts = nothing
-
set fso = nothing
-
-
'end of program
-
-
Function generatePassword(PASSWORD_LENGTH)
-
-
Dim NUMLOWER, NUMUPPER
-
Dim newPassword, count, pwd
-
-
NUMLOWER = 48 ' 48 = 0
-
NUMUPPER = 57 ' 57 = 9
-
-
' initialize the random number generator
-
Randomize()
-
-
newPassword = ""
-
count = 0
-
DO UNTIL count = PASSWORD_LENGTH
-
-
pwd = Int( ( NUMUPPER - NUMLOWER + 1 ) * Rnd + NUMLOWER )
-
-
newPassword = newPassword + Chr( pwd )
-
-
count = count + 1
-
-
Loop
-
-
'The password is good so return it
-
generatePassword = newPassword
-
End Function
1 1580
It looks to me like you have two separate and independent functions doing the same thing here. Did you write these?
If you are only trying to generate a random password by double-clicking, you should be able to use the second function (starting with line 86 of your code), you'll need to pass it the length, but in the double click event of your text box, write this kind of code:
This code will pass the password length of 6 characters.
The generatePasswor d function will, of course, go into a standard code module as a Public Function.
From what I can tell just looking at this, the first function you have is a highly specific password generator possibly for a banking institution?
Regards,
Scott
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Pat Scott |
last post by:
I am looking for a general purpose javascript snippet that enables me to
<div> or <span> HTML to make portions of the form be hidden and then appear.
The form contains about 12 sections and some sections can contain
subsections. When the user clicks on a checkbox, I want previously hidden
text boxes, radio buttons, text, drop down menus, and additional checkboxes
to appear. In some cases, clicking on a checkbox in a section can cause...
|
by: Dutchy |
last post by:
Hi there,
After spending several hours trying all I could imagine and search for in
Google I gave up. In a continuous form I want to sort the choosen column by
clicking the header (label) of that column. I even want to sort up and down
if one clicks again on the same header. No problem so far, all works well
for one column. Now I want to sort on the first choosen column ASC or DESC
and additionally on a second column ASC.
I use the...
|
by: Heather Crow |
last post by:
I have a VS.NET 2003 Visual Basic form which keeps hanging. It does not
appear to matter what textbox I am on. When trying to edit the field I
cannot move focus from this field to another. Clicking buttons etc. does
nothing and the focus remains with the field I had been editing. The text
boxes are bound to a record in a SQL database.
|
by: DoctorV3774 |
last post by:
We developed a small test database that we are using to attempt to connect to a wsdl to consume web services. The database form contains 3 fields and a submit button on the form. At the bottom I've included the code behind the button on the form and the class module code that was generated by the Web Service Tool.
I've added a little bit of information that pertains to the Access Database and our process and expected results:
VBA for...
|
by: sklett |
last post by:
I've got a odd thing happening when tabbing through my form. everything is
fine as long as I only tab through the fields, but if I skip 10 fields and
click in a field, enter data then hit tab it will just to the control AFTER
the last control I TABBED to.
This doesn't make sense to me. Does a form keep track of tab index? Do I
need to set this index somewhere when clicking on a field?
Thanks for any help!
| |
by: LANTEK |
last post by:
I am currently working on a form that would have multiple fields plus an upload file spot. I cannot add the code for the upload file. Also, after clicking submit the form should send an email to the specified email address and currently those emails are not being recieved. All that happens is the php code box ocomes up and lets the user know that the form has been submitted and doesn't re-direct to the thank you page..Please help
Here is my...
|
by: Paul Furman |
last post by:
I'm getting incorrect response when hitting the enter key instead of
actually clicking the button on a form. It activates but the post data
isn't being sent I think. The php generated page
flickers & reloads but doesn't perform the update.
This is php generated, I'm just pasting the page source (reformatted &
extra junk removed and I think they are now identical), and it's running
on my localhost apache server for testing so maybe...
|
by: google |
last post by:
In a continuous form the following code is under a button in the form
header. In Access 2003 and earlier, this goes to a new record, then
adds
relevant data to that new record.
DoCmd.GoToRecord , , A_NEWREC
If <some codeThen
= "CA002"
Else
|
by: ljstern |
last post by:
Hello. I am using MS Access 2003 with XP/pro. I have a form that has the following properties set through the property sheet:
form: AllowAdditions = False
CartridgeID field: Locked = True
The AllowAdditions property is set so that the user can navigate through the records but not be able to begin a new record without clicking the New Record button. The ID field is locked so the user cannot change that field, while still being able to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |