求简单的VB程序

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:41:01
用随即函数产生一个1~100之间的随机数X,

3x-5,x>=50
y=
2x+6,x<50

dim i as integer
i = int(rnd * 99)+1
if i >= 50 then msgbox 3*i-5
if i < 50 then msgbox 2*i+6

Private Sub Command1_Click()
Randomize
x = Int(Rnd * 100 + 1)

If x >= 50 Then
y = 3 * x - 5
Else
y = 2 * x + 6
End If
MsgBox y
End Sub

dim x,y
x=rnd*100
if x>=50 then
y=3*x-5
else
y=2*x+6
end if
print y;