22-08-13, 07:24 PM
MSDOS كتب :استخدمت دالة للعضو @@أبورائد@@
جربتها كالتالي
كود :
Public Class Form1
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
If Me.ListBox1.Items.Count > 0 Then
Dim arr() As Integer = RageRandom(0, Me.ListBox1.Items.Count - 1)
Dim itm() As Object = New ArrayList(Me.ListBox1.Items).ToArray
Me.ListBox1.Items.Clear()
For Each i As Integer In arr
Me.ListBox1.Items.Add(itm(i))
Next
End If
End Sub
#Region " RageRandom (minValue As Integer, maxValue As Integer) As Array "
Public Function RageRandom(ByVal minValue As Integer, ByVal maxValue As Integer) As Array
If (minValue < 0) Or (minValue >= maxValue) Then Return Nothing
minValue += 1 : maxValue += 1
Dim mArray(maxValue - minValue) As Integer
For i = 0 To (maxValue - minValue)
[lp]: Randomize()
Dim mValue As Integer = CInt(Int((maxValue * Rnd()) + minValue))
For Each r In mArray
If mValue = r Or mValue > maxValue Then GoTo [lp]
Next
mArray(i) = mValue
Next
For i = 0 To mArray.Length - 1
mArray(i) -= 1
Next
Return mArray
End Function
#End Region
Private Sub Button1_Click_1(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox2.Text)
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
End Class
100%
بالتوفيق

