VB中如何设置随机数的随机率,VB中产生随机数

浩唐网络 行业资讯 2022-01-05 07:45 6次
网友回答呵呵,可以先用一个随机数确定你想要的出现概率,再在相应的概率里生成相应的取值范围,写个代码,参考一下吧:  Private Sub Command1_Click()  Dim M, A As Integer  Randomize  A = Int(Rnd * 100) + 1  Select Case A  Case 1 To 20  M = Int(Rnd * 9) + 1  Case 21 To 55  M = Int(Rnd * 9) + 11  Case 56 To 100  M = Int(Rnd * 9) + 21  End Select  Print M  End Sub网友回答Private Sub cmdRanAngle_Click()  Dim dblAngle As double  Dim dblSin As double  'Randomize  dblAngle = dbl((90*ran)+60)  dblSin = sin(dblAngle)  lblScream.Caption = dblAngle  lblAnswer.caption = dblSin  End sub   最简单的方法,楼上都有错。。。。。  希望楼主采纳,有VB问题希望可以探讨,QQ827170254