網路城邦
上一篇 回創作列表 下一篇   字體:
【電腦軟體設計】電腦軟體設計-丙級-術科測驗1站-第2題
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

執行畫面


( 休閒生活網路生活 )
回應 推薦文章 列印 加入我的文摘
上一篇 回創作列表 下一篇

引用
引用網址:https://classic-blog.udn.com/article/trackback.jsp?uid=zdzo&aid=2740034