パスワードを作成する RNGCryptoServiceProvider 
 		
	
	 
 
Public Class Form1 
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
        Dim x As Integer 
        Dim i As Integer 
        Dim StrAry As String = "ABCDEFGHIJKLNMOPQRSTUVWXYZ" _ 
                            & "abcdefghijklnmopqrstuvwxyz" _ 
                            & "0123456789" 
 
        Dim PasW As StringBuilder 
        Do 
            PasW = New StringBuilder 
            For x = 0 To 9 
                'Debug.WriteLine(RollDice(6)) 
                PasW.Append(StrAry.Chars(RollDice(62))) 
            Next x 
            i = i + 1 
            Application.DoEvents() 
 
            Me.TextBox1.Text = Me.TextBox1.Text & vbCrLf & PasW.ToString 
            Debug.Print(i.ToString) 
 
        Loop Until i = 3000 
 
    End Sub 
 
ここから下はMSから引用↓ 
    ' This method simulates a roll of the dice. The input parameter is the  
    ' number of sides of the dice. 
    Public Function RollDice(ByVal NumSides As Integer) As Integer 
        ' Create a byte array to hold the random value. 
        Dim randomNumber(0) As Byte 
 
 
        ' Create a new instance of the RNGCryptoServiceProvider.  
        Dim Gen As New RNGCryptoServiceProvider() 
 
        ' Fill the array with a random value. 
        Gen.GetBytes(randomNumber) 
 
        ' Convert the byte to an integer value to make the modulus operation easier. 
 
        Dim rand As Integer = Convert.ToInt32(randomNumber(0)) 
 
        ' Return the random number mod the number 
        ' of sides.  The possible values are zero- 
        ' based, so we add one. 
        Return rand Mod NumSides 
 
 
    End Function 'RollDice 
 
End Class
 
  |  
  
	
	
	
	
	
	
	 
	
 
	
	 |