Dim MyValue
MyValue = Int((9 * Rnd) + 1)  

解决方案 »

  1.   

    randomize
    clng(rnd * 8) + 1
      

  2.   

    Dim MyValue
    Randomize   ' 对随机数生成器做初始化的动作。MyValue = Int((9* Rnd) + 1)   ' 生成 1 到 9之间的随机数值。
      

  3.   

    to:Jneu(沧海桑田) 
       为什么取7的几率远远的大于其他???
    to:hhdsq(笨笨) 
       为什么取5的几率远远的大于其他???
      

  4.   

    那么,怎么从 a,d,e,i,k,m 中随机的取一个呢?
      

  5.   

    dim strChar(5) as string
    dim strMyChar  as string
    dim intValue as integer
    strChar(0)="a"
    strChar(0)="d"
    strChar(0)="e"
    strChar(0)="i"
    strChar(0)="k"
    strChar(0)="m"
    Randomize
    intValue=int(Rnd*6)
    strMyChar=strChar(intValue)
      

  6.   

    function getRandom(limit as int) as int
      randomize
      getRandom = int(rnd * limit)
    end functiondim s(5) as string
    s(0)="a"
    s(1)="d"
    s(2)="e"
    s(3)="i"
    s(4)="k"
    s(5)="m"s(getRandom(6))