ljsq.net
当前位置:首页 >> 求一个可以从0到9之间任意5个数组合的VB编码谢谢 >>

求一个可以从0到9之间任意5个数组合的VB编码谢谢

代码及注释如下: Private Sub Command1_Click()'点击命令按钮执行程序 Randomize'初始化随机数发生器 x = Round((Rnd() * 9), 0)'先利用随机数得到0-1区间的小数,然后乘以9,在对这个数进行四舍五入后,赋值给x Print x'窗体打印x End Sub

Private Sub Command1_Click()Dim a(1 To 5, 1 To 5) Text1.Text = ""For i = 1 To UBound(a, 1) For j = 1 To UBound(a, 2) Randomize a(i, j) = Int(10 * Rnd) Text1.Text = Text1.Text & Str(a(i, j)) Next j Text1.Text = Text1.Text & vbCr...

Private Sub Command1_Click()Dim i As Integer, j As Integer, a(6, 6) As IntegerFor i = 1 To 6 For j = 1 To 6 Randomize a(i, j) = Fix(Rnd * 10) Print a(i, j); Next PrintNextPrintFor i = 1 To 6 For j = 1 To 6 Print i & j & " "; Ne...

可以写,能不能加财富值?

'新建一个窗体,在上面拖一个按钮,然后双击按钮,编写按钮的点击事件代码Dim i As Integer Dim sum As Integer sum = 0 For i = 0 To 100 If i Mod 2 = 0 Or i Mod 3 = 0 Then sum = sum + i End If Next MsgBox "0~100之间能被2或3整除的所有...

Private Sub Form_Click() Dim n, a, max As Integer n = 1 max = Int(Rnd * 101 + 100) Print max; Do n = n + 1 a = Int(Rnd * 101 + 100) Print a; If a > max Then max = a Loop While n < 10 Print Print maxEnd Sub

取模运算可以这样理解: 9 mod 1=0 9 /1 =9 .....0 1*9 +0 =9 9 mod 2 = 1 9/2 =4.....1 2*4+1 = 9 取模就是求余数 除数/被除数=商 +余数 另外要注意 运算顺序: 符号 说明 优先级 ^ 指数 1 - 取负 2 * 乘 3 / 除 3 \ 整除 4 mod 求余 5 + 加 6 ...

Dim d(9) As Integer Dim i As Integer Dim n As Integer Dim x As Integer Randomize n = 0 Do While n < 9 x = Int(Rnd * 9) For i = 1 To n If x = d(i) Then Exit For Next i If i > n Then n = n + 1 d(n) = x End If Loop '输出显示检验一...

每5个一行,换行的判断 If i Mod 5 = 0 Then Print 改成 (i 该成 n) If n Mod 5 = 0 The Print --------------------- Dim i As Integer, j As Integer, n As Integer n = 0 For i = 2 To 300 For j = 2 To i - 1 If i Mod j = 0 Then Exit Fo...

你哪个地方不会做?

网站首页 | 网站地图
All rights reserved Powered by www.ljsq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com