張琍婷EXCEL VBA雙迴圈JavaScript迴圈
VBA繪圖
VBA繪圖程式碼
Option Explicit Const topleft As String = "C5" ' anchor cell Const diam As Integer = 100 ' points diameter直徑 Dim Shp As Shape ' =========================== Sub 張琍婷() Dim TLCleft As Double Dim TLCtop As Double Dim i As Integer '宣告整數integer For i = 1 To 30 TLCleft = 20 * i TLCtop = 20 * i Set Shp = ActiveSheet.Shapes.AddShape(Type:=msoShapeOval, _ Left:=TLCleft, Top:=TLCtop, _ Width:=diam, Height:=diam) With Shp .Fill.Visible = msoFalse .Line.Weight = 10 .Line.ForeColor.Brightness = 0.4 .ThreeD.BevelTopType = msoBevelCircle End With Next With Cells(1, 1) .Value = "張琍婷" .Interior.Color = RGB(255, 192, 103) With .Font .Size = 20 .Color = RGB(255, 255, 255) .Bold = True End With End With End Sub Sub 張琍婷刪除() For Each Shp In ActiveSheet.Shapes Shp.Delete Next End Sub
劉任昌112影片
輸出
EXCEL雙迴圈
'變數variables應該要宣告 pre=preserve保留 'Dimension宣告指令 Option Explicit Dim i, j As Integer Public Sub 豬八戒() For i = 2 To 7 For j = 1 To 6 Cells(i, j).Value = i * j Cells(i, j).Font.Color = RGB(0, 0, 255) Cells(i, j).Font.Bold = True Next Next End Sub 相當於JavaScript指令}代表結束VBA不用{}代表開始與結束,sub end sub
JavaScript迴圈
<head>
<style>
h1{padding: 20px; background-color: pink; 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>
留言
張貼留言