林文慈EXCEL與JavaScript迴圈
輸出
JavaScript迴圈
<head><style>
h1{padding: 20px; background-color: green; color: white;}
</style>
<script>
function year()
{ var tmp ="<font size=5 color=#0000FF>"; //輸出HTML指令preserve格式
for (var i=0 ; i<= 5; i++)
{ tmp = tmp + (i+2020) +"年";
for (var j=1; j<13; j++)
{ tmp=tmp + j +"月";
}
tmp = tmp +"<br/>";
}//tmp 是一個字串變數+進行字串的串接加上<br/>html換列命令
tmp = tmp + "</font>";
document.getElementById("out").innerHTML = tmp;
}
</script>
</head>
<input onclick="year()" type="button" value="超級美女" />
<p id="out">輸出</p>
EXCEL迴圈
'變數variables應該要宣告 pre=preserve保留
Option Explicit '要求所有變數必須宣告才能使用
Dim i, j As Integer
'Dimension 宣告指令
Public Sub 林文慈()
Cells(1, 1).Value = 12345
Cells(1, 1).Font.Color = RGB(0, 0, 256)
Cells(1, 1).Font.Bold = True
End Sub
Public Sub 孫悟空()
For i = 1 To 7
For j = 1 To 5
Cells(i, j).Value = i * j
Next
Next
End Sub
林文慈的JavaScript迴圈
<script>
function year()
{ var tmp ="<font size=5 color=#0000FF>"; //輸出HTML指令preserve格式
for (var i=0 ; i<= 10; i++)
{ tmp = tmp + (i+2010) +"年<br/>"
}
tmp = tmp + "</font>"
document.getElementById("out").innerHTML = tmp;
}
</script>
<body>
<input onclick="year()" type="button" value="林文慈年" />
<p id="out">輸出</p>
</body>
留言
張貼留言