22/05/11 11:22
DavidP
Imports System Imports System.IO Imports System.Text Public Class Form1 Dim Buchstaben As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" Dim r As New Random Dim conto As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click conto = conto + 4 Label1.Text = "Password generate: " & conto For i As Integer = 1 To NumericUpDown1.Value generieren() Next TextBox1.Text = TextBox1.Text & vbNewLine End Sub Private Sub generieren() If CheckBox1.Checked = True And CheckBox2.Checked = False And CheckBox3.Checked = False Then Try TextBox1.Text += Buchstaben.Substring(r.Next(1, 26), 1) Catch ex As Exception MsgBox(ex.Message) End Try ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = False Then Try TextBox1.Text += Buchstaben.Substring(r.Next(1, 52), 1) Catch ex As Exception MsgBox(ex.Message) End Try ElseIf CheckBox1.Checked = True And CheckBox2.Checked = True And CheckBox3.Checked = True Then Try TextBox1.Text += Buchstaben.Substring(r.Next(1, 62), 1) Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" conto = 0 Label1.Text = "Password generate: " & conto End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim percorso As String Dim contenuto As String percorso = "C:\password.txt" contenuto = TextBox1.Text File.WriteAllText(percorso, contenuto) End Sub End Class
allora le mie domande sono:
Il mio programma cosi è veloce?
come posso leggere lettere in arrey ad esempo dalla 1 a 26(lettere maiuscole) e da 56a 62(numeri) in modo da creare una password di sole lettere maiuscole e numeri?
Ho allegato anche un immagine per farvi vedere come l'ho strutturato.
P.S. nell' immagine c'è anche lo spunto per i simboli ma per ora è inutilizzato
Grazie infinite
DavidP
aaa