a3deluxe Posted March 31, 2012 at 01:12 PM Report #446767 Posted March 31, 2012 at 01:12 PM Boas criei um gera de passwords com 3 letras e 5 números mas gera tudo baralhado, para isso criei txtbox individuais. Eu queria que ele gera-se tudo junto mas primeiro as letras depois os números. aqui fica o código: Private Sub Command1_Click() Text1 = GenerateCode() End Sub Public Function GenerateCode() strInputString = "012356789" intLength = Len(strInputString) intNameLength = 5 ' Randomize strName = "" For intStep = 1 To intNameLength intRnd = Int((intLength * Rnd) + 1) strName = strName & Mid(strInputString, intRnd, 1) Next GenerateCode = strName End Function Public Function GenerateCode2() strInputString = "abcdefghijklmnqsuvwxyz" intLength = Len(strInputString) intNameLength = 3 ' Randomize strName = "" For intStep = 1 To intNameLength intRnd = Int((intLength * Rnd) + 1) strName = strName & Mid(strInputString, intRnd, 1) Next GenerateCode2 = strName End Function Private Sub Command2_Click() End End Sub Private Sub Form_Load() End Sub HELP
JRS Posted March 31, 2012 at 03:06 PM Report #446779 Posted March 31, 2012 at 03:06 PM Faz mais simples : primeiro as letras Private Sub Command1_Click() strN = "0123456789" strA = "abcdefghijklmnopqrstuvxyz" strPW = "" For i = 1 To 3 Randomize intRnd = Int((Len(strA) * Rnd) + 1) strPW = strPW & Mid(strA, intRnd, 1) Next i For i = 1 To 5 Randomize intRnd = Int((Len(strN) * Rnd) + 1) strPW = strPW & Mid(strN, intRnd, 1) Next i Label1.Caption = strPW End Sub
a3deluxe Posted March 31, 2012 at 04:44 PM Author Report #446793 Posted March 31, 2012 at 04:44 PM JRS obrigado pela ajuda! como coloco para gerar numa Text1?
a3deluxe Posted March 31, 2012 at 05:24 PM Author Report #446797 Posted March 31, 2012 at 05:24 PM JRS problema resolvido. strN = "0123456789" strA = "abcdefghijklmnopqrstuvxyz" strPW = "" For i = 1 To 3 Randomize intRnd = Int((Len(strA) * Rnd) + 1) strPW = strPW & Mid(strA, intRnd, 1) Next i For i = 1 To 5 Randomize intRnd = Int((Len(strN) * Rnd) + 1) strPW = strPW & Mid(strN, intRnd, 1) Next i Text1 = strPW End Sub muito obrigado.
a3deluxe Posted March 31, 2012 at 05:30 PM Author Report #446799 Posted March 31, 2012 at 05:30 PM Jurgiu-me outra dúvida. como posso fazer com um só botão gerar em varias passwords em varias textboxs??
JRS Posted March 31, 2012 at 05:51 PM Report #446801 Posted March 31, 2012 at 05:51 PM Faça um loop (For tx=1 to nx) externo e replique o Text1 (ctrl c, ctrl v na form) e quando pedir se quer com o mesmo nome (Text1) e indexado clique ok, ou seja, Text1(0), Text1(1), Text1(2)..........quantos forem necessarios, ou seja, nx e considere o 0 ---> Text1(nx-1)......
a3deluxe Posted March 31, 2012 at 06:29 PM Author Report #446810 Posted March 31, 2012 at 06:29 PM Obrigado!! Resolvido... Abraço
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now