劉任昌EXCEL與JavaScript迴圈

輸出

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: 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>

網頁顏色

留言

  1. https://danley1116.blogspot.com/2021/11/exceljavascript.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

程式交易054美國2010年5月6日閃崩

陳佑愷2023Q2期貨分析人員測驗「期貨、選擇權與其他衍生性商品」

陳佑愷程式交易、演算法交易的風險管理