12-12-15, 05:31 PM
حبيبي ميمو
هاد كامل الكود مع "طريقة الاستخدام" واذا مش واضح خبرني
هاد كامل الكود مع "طريقة الاستخدام" واذا مش واضح خبرني
كود :
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = RandomChars(CheckBox1.Checked, CheckBox2.Checked, CheckBox3.Checked, NumericUpDown1.Value)
End Sub
Shared Function RandomChars(ByVal m_CapitalChars_AZ As Boolean, ByVal m_SmallChars_az As Boolean, ByVal m_numbers_09 As Boolean, ByVal length As Integer) As String
Dim charset As String = ""
If m_CapitalChars_AZ Then charset &= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
If m_SmallChars_az Then charset &= "abcdefghijklmnopqrstuvwxyz"
If m_numbers_09 Then charset &= "0123456789"
Dim result As String = ""
If charset <> "" Then
Static r As New Random ' Static مهم اختياره
For i = 1 To length
result &= charset(r.Next(0, charset.Length))
Next
End If
Return result
End Function
End Class