How to move value in ListBox2(with Duplicate value) to ListBox4 (Non Duplicate value)? The condition, each value must >= or <= 3 from other.
For example:
Each ListBox have 5 values.
ListBox2:
6
8
8
12
15
ListBox4:
6
9 --> 8 become 9, because 8-6=2 (Must >= 3)
20 --> 8 become 20, because we random the value
12
15
Here's my code :
Private Sub MaxGenome_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MaxGenome.TextChanged
Dim i, nilai As Integer
ListBox2.Items.Clear()
ListBox4.Items.Clear()
For i = 1 To CInt(PjgGen.Text)
nilai = GeneticAlgorithm.PopuMain.Best_member.Genome(i)
If Not (ListBox4.Items.Contains(nilai - 1) OrElse ListBox4.Items.Contains(nilai - 2) OrElse ListBox4.Items.Contains(nilai) OrElse ListBox3.Items.Contains(nilai + 1) OrElse ListBox4.Items.Contains(nilai + 2)) Then
ListBox4.Items.Add(nilai)
Else
While (ListBox4.Items.Contains(nilai - 1) OrElse ListBox4.Items.Contains(nilai - 2) OrElse ListBox4.Items.Contains(nilai) OrElse ListBox3.Items.Contains(nilai + 1) OrElse ListBox4.Items.Contains(nilai + 2))
Do
nilai = Rand_between(1, CInt(record.Text))
Loop
If Not (ListBox4.Items.Contains(nilai - 1) OrElse ListBox4.Items.Contains(nilai - 2) OrElse ListBox4.Items.Contains(nilai) OrElse ListBox3.Items.Contains(nilai + 1) OrElse ListBox4.Items.Contains(nilai + 2)) Then
ListBox4.Items.Add(nilai)
End If
End While
End If
ListBox2.Items.Add(GeneticAlgorithm.PopuMain.Best_member.Genome(i))
Next i
End Sub
This operation begin when
TextBox2.TextChanged
. Every
TextBox2.TextChanged
, this operation will be called. I'm clear the ListBox Item for space to the next value.
Sorry my english is bad, just focus on the example, that's the main point of my question, thanks Smile :)