Private Sub btnGen_Click(sender As System.Object, e As System.EventArgs) Handles btnGen.Click
Dim r, i, Counter, Numb, Length
Dim Password As String
Counter = -0
If lstPass.Items.Count <= numLength.Value Then
Length = numLength.Value
Numb = numHowMany.Value
If Numb = 0 Then
MsgBox("You need to enter the amount of Passwords that you want Generated.", vbOKOnly + vbCritical, "How Many?")
Else
Length = numLength.Value
If Length = 0 Then
MsgBox("You need to enter the Length of the Passwords you want to create.", vbOKOnly + vbCritical, "How Long?")
Else
While Counter <= Length - 1
Counter = Counter + 1
Password = ""
For i = 1 To Numb
Randomize()
r = Int((Rnd() * 61) + 1)
Password = Password & Mid(Chars, r, 1)
Next i
lstPass.Items.Add(Password)
End While
btnGen.Enabled = False
btnClear.Enabled = True
End If
End If
Else
lstPass.Items.Clear()
btnGen.Enabled = True
btnClear.Enabled = False
End If
End Sub
Number boxes are being switched
Page 1 of 15 Replies - 146 Views - Last Post: 05 February 2013 - 04:33 AM
#1
Number boxes are being switched
Posted 04 February 2013 - 06:21 PM
There is an issue with this code which is when the program is run it will generate the correct passwords, but when the Clear button is pressed the NumHowMany & numLength is incorrect it swaps the 2 around, can anyone see any issues? if u need more info please ask. Hope i explained well.
Replies To: Number boxes are being switched
#2
Re: Number boxes are being switched
Posted 04 February 2013 - 08:37 PM
You are saying that problem occurs when the clear button is pressed and yet you are posting codes from btnGen_Click , pleas post codes from Clear button
#3
Re: Number boxes are being switched
Posted 04 February 2013 - 08:53 PM
Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click
lstPass.Items.Clear()
btnGen.Enabled = True
btnClear.Enabled = False
End Sub
it does it even if the clear button is not pressed. If u generate the password then try and change the numbers it swaps the values also.
Its as if there is a third value and its skipping to increment it.
#4
Re: Number boxes are being switched
Posted 04 February 2013 - 09:13 PM
Just please post all your code
#5
Re: Number boxes are being switched
Posted 04 February 2013 - 09:45 PM
PNJLj, on 04 February 2013 - 07:21 PM, said:
There is an issue with this code which is when the program is run it will generate the correct passwords, but when the Clear button is pressed the NumHowMany & numLength is incorrect it swaps the 2 around, can anyone see any issues? if u need more info please ask. Hope i explained well.
You are counting generated passwords with Length, and generating the passwords with Numb.
Should be
While Counter <= Numb - 1
Counter = Counter + 1 ' !!
Password = ""
For i = 1 To Length ' !!
Randomize()
r = Int((Rnd() * 61) + 1)
Password = Password & Mid(Chars, r, 1)
Next i
lstPass.Items.Add(Password)
End While
#6
Re: Number boxes are being switched
Posted 05 February 2013 - 04:33 AM
Thankyou so much, That fixed the problem.
Much Appreciated.
Much Appreciated.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|