乘法口诀表
原VBA代码中下:
Option Explicit
Sub 乘法表() Dim r As Integer, c As Integer r = 1 Do While r < 10 c = 1 Do While c <= r Cells(r, c).Value = c & "*" & r & "=" & c * r Cells(r, c).Borders.LineStyle = xlContinuous c = c + 1 Loop r = r + 1 Loop End Sub |
乘法练习题:使用数组配合循环实现。
Sub 乘法练习2使用数组() Dim c%, r%, i% Dim arr() arr() = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 9) r = 1 Do While r <= 20 c = 1 Do While c <= 6 Cells(r, c) = arr(Int(Rnd() * 10)) & "*" & arr(Int(Rnd() * 10)) & "=" c = c + 1 Loop r = r + 1 Loop End Sub |
|
|
|
|