字體:小 中 大 | |
|
|
2010/02/19 22:02:51瀏覽1924|回應0|推薦3 | |
FOR迴圈版 Private Sub cmd_no2_Click() '************************** '*119-940302 Program Start* '************************** Open "A:\940302.SM" For Input As #1 Input #1, n Close #1 For i = 1 To n For j = 1 To i S = S & j Next j S = S & vbCrLf Next i Txt_no2.Text = "第二題結果:" & vbCrLf & S End Sub DO WHILE 前測試版 Private Sub cmd_no2_Click() '************************** '*119-940302 Program Start* '************************** Open "A:\940302.SM" For Input As #1 Input #1, n Close #1 i = 1 Do While i <= n j = 1 Do While j <= i S = S & j j = j + 1 Loop i = i + 1 S = S & vbCrLf Loop Txt_no2.Text = "第二題結果:" & vbCrLf & S End Sub DO WHILE 後測試版 Private Sub Cmd_no2_Click() '************************** '*119-940302 Program Start* '************************** Open "A:\940302.SM" For Input As #1 Input #1, n Close #1 i = 1 Do j = 1 Do S = S & j j = j + 1 Loop While j <= i i = i + 1 S = S & vbCrLf Loop While i <= n txt_no2.Text = "第二題結果:" & vbCrLf & S End Sub 執行畫面 |
|
( 休閒生活|網路生活 ) |