Different numbers from 1 to 10

前端 未结 5 1082
太阳男子
太阳男子 2020-12-02 00:20

I want to generate 10 different numbers from a range of 0-9. the desired output may look like this, 9 0 8 6 5 3 2 4 1 7

Dim arraynum(9) As Integer
Dim crmd A         


        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 01:06

    Having no performance requirements specified, I would use the below short and simple code:

    Randomize
    With CreateObject("Scripting.Dictionary")
        Do
            .Item(Int(Rnd * 10)) = ""
        Loop Until .Count = 10
        MsgBox Join(.Keys)
    End With
    

提交回复
热议问题