vb.net 随机生成RGB色,但不能重覆RGB色值

vb.net 随机生成RGB色,但不能重覆RGB色值

问题描述:

我想生成一个随机且不重覆的RGB色值,100组(实际上不一定,可能更少或更多)

我通过while载入100组RGB色,请问这个产生随机RGB的函数怎么写呢?

Dim rowIndex as long=0
While rowIndex < 100
    mytb.Rows(rowIndex).Item(0)=此处载入RGB色的函数
    rowIndex+=1
End While

谢谢
使用vb.net

Dim rnd As New Random
Dim arr(0 To 99) As Long
Dim rowIndex as long=0
While rowIndex < 100
    Do
        r = rnd.NextInt()
        if arr.Take(rowIndex).All(Function(x) x <> r) exit do
        Loop
    mytb.Rows(rowIndex).Item(0)=r
        arr(rowIndex) = r
    rowIndex+=1
End While

你好 Caozhy
图片说明
我这里打出来会错
我希望输出的值是 比如 255,0,255 或 233,111,333 这样的格式