12-08-22, 12:37 PM
السادة
هذا كود يعرض 3 اسماء عشوائية
Dim array As String() = New String(DataGridView1.Rows.Count - 1) {}
For i As Integer = 0 To DataGridView1.Rows.Count - 1
array(i) = DataGridView1.Rows(i).Cells("name").Value
Next
For i = 1 To 3
Dim arrNames As Array = array
Dim rand As New Random
Dim rndIndex As Integer = rand.Next(0, arrNames.Length)
Dim rndName As String = arrNames(rndIndex)
MsgBox(rndName)
Next
لعدم خبرتي بالمصفوفات
ارغب في عدم تكرار عنصر
اي
اضع شرط في حالة وجود العنصر يعرض عنصر بدلا منه
شكرا
هذا كود يعرض 3 اسماء عشوائية
Dim array As String() = New String(DataGridView1.Rows.Count - 1) {}
For i As Integer = 0 To DataGridView1.Rows.Count - 1
array(i) = DataGridView1.Rows(i).Cells("name").Value
Next
For i = 1 To 3
Dim arrNames As Array = array
Dim rand As New Random
Dim rndIndex As Integer = rand.Next(0, arrNames.Length)
Dim rndName As String = arrNames(rndIndex)
MsgBox(rndName)
Next
لعدم خبرتي بالمصفوفات
ارغب في عدم تكرار عنصر
اي
اضع شرط في حالة وجود العنصر يعرض عنصر بدلا منه
شكرا