九九乘法表excel代码,用excel做九九乘法表结果

首页 > 实用技巧 > 作者:YD1662023-05-15 04:51:41

通过九九乘法表来练习如何使用VB双循环。以下代码对VBA,VB,VB.net适用

九九乘法表excel代码,用excel做九九乘法表结果(1)

'九九乘法表

Dim excel As New excel

Dim ws = excel.activesheet

ws.清除内容()

ws.清除背景色()

Dim r, c, t As Integer

Dim 开始行, 开始列 As Integer

开始行 = 2

开始列 = 3

ws.cells(开始行, 1) = "样式1:先行后列"

For c = 1 To 9

For r = c To 9

t = r * c

ws.cells(r 开始行, c 开始列 - 1) = c & "*" & r & "=" & t

Next

Next

开始行 = 12

ws.cells(开始行, 1) = "样式2:先列后行"

For r = 1 To 9

For c = r To 9

t = r * c

ws.cells(r 开始行, c 开始列 - 1) = r & "*" & c & "=" & t

Next

Next

开始行 = 22

ws.cells(开始行, 1) = "样式3:对照式"

For c = 1 To 9

For r = 1 To 9

t = r * c

If r >= c Then ws.set单元格背景色(r 开始行, c 开始列 - 1, Color.Green)

ws.cells(r 开始行, c 开始列 - 1) = r & "*" & c & "=" & t

Next

Next

九九乘法表excel代码,用excel做九九乘法表结果(2)

栏目热文

文档排行

本站推荐

Copyright © 2018 - 2021 www.yd166.com., All Rights Reserved.