计算所有可能的组合[RGB]

时间:2013-12-16 08:26:51

标签: vb.net math

我制作了一个生成随机RGB值的简单程序,但我不知道如何计算RGB代码的所有可能组合。可能会尽快生成它们,任何人都可以帮助我吗?

计算部分代码:

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    r1 = CInt(Int((255 * Rnd()) + 0))
    g1 = CInt(Int((255 * Rnd()) + 0))
    b1 = CInt(Int((255 * Rnd()) + 0))
    If ListBox1.Items.Contains(r1 & "," & g1 & "," & b1) Then
        'number is clone of any number in Listbox1.items
        Label2.Text = Label2.Text + 1
    Else
        ListBox1.Items.Add(r1 & "," & g1 & "," & b1)
        Label1.Text = ListBox1.Items.Count.ToString
    End If
End Sub

1 个答案:

答案 0 :(得分:0)

足够工作;)

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    r1 = CInt(Int((255 * Rnd()) + 0))
    g1 = CInt(Int((255 * Rnd()) + 0))
    b1 = CInt(Int((255 * Rnd()) + 0))
    If ListBox1.Items.Contains(r1 & "," & g1 & "," & b1) Then
        'number is clone of any number in Listbox1.items
        Label2.Text = Label2.Text + 1
    Else
        ListBox1.Items.Add(r1 & "," & g1 & "," & b1)
        Label1.Text = ListBox1.Items.Count.ToString
    End If
End Sub