主题:vb菜鸟求教.~~~高人指点一下.~
题目:要随机生成1个大于100小于1000的数字出来.把这些数字当作人民币.
然后要把他分开.多少个100元.50元.20元.10元......
已经做到这样楽..请指教一下.~~
Private Sub Command1_Click()
Cls
s = Int((Rnd * 400 + 100) * 100) / 100
Text1.Text = s
Dim x(13) As Integer
x(1) = 10000
x(2) = 5000
x(3) = 2000
x(4) = 1000
x(5) = 500
x(6) = 200
x(7) = 100
x(8) = 50
x(9) = 20
x(10) = 10
x(11) = 5
x(12) = 2
x(13) = 1
i = 1
s = s * 100
k = s \ x(i)
Do While i <= 13
List1.AddItem Str(x(i) / 100 & "元" & Str(k) & "张")
s = s - k * x(i)
i = i + 1
If i >= 14 Then
Exit Do
End If
k = s \ x(i)
Loop
End Sub
然后要把他分开.多少个100元.50元.20元.10元......
已经做到这样楽..请指教一下.~~
Private Sub Command1_Click()
Cls
s = Int((Rnd * 400 + 100) * 100) / 100
Text1.Text = s
Dim x(13) As Integer
x(1) = 10000
x(2) = 5000
x(3) = 2000
x(4) = 1000
x(5) = 500
x(6) = 200
x(7) = 100
x(8) = 50
x(9) = 20
x(10) = 10
x(11) = 5
x(12) = 2
x(13) = 1
i = 1
s = s * 100
k = s \ x(i)
Do While i <= 13
List1.AddItem Str(x(i) / 100 & "元" & Str(k) & "张")
s = s - k * x(i)
i = i + 1
If i >= 14 Then
Exit Do
End If
k = s \ x(i)
Loop
End Sub